I am trying to connect my Netduino Mini to a MikroE MMC/SD reader via SPI, using the new firmware v. 4.1.1.0 a3, and the sample code provided by Chris
The error that I got is a SPI error, which is reported by my analyzer Salae Logic as "The initial state of the CLK line does not match the settings". I have googled for this error but have not found any reference. As you can see on the diagram below,
CS goes low, and SPCK pulses high. So I am wondering what is wrong with this. Maybe this will ring a bell in the case you have seen this error already.
Available information: breadboard schema and chronogram.
I have also attached (at the bottom of the post) the Salae Logic file, that can be replayed. Finally, here is the code, which is pretty much what Chris provided:
using System; using System.Threading; using Microsoft.SPOT; using System.Text; using System.IO; using System.IO.Ports; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoMini; using SecretLabs.NETMF.IO; namespace NetduinoMiniApplication1 { public class Program { public static void Main() { // default CS pin on Netduino Mini is Pin 13: StorageDevice.MountSD("SD1", SPI_Devices.SPI1, Pins.GPIO_PIN_13); string[] directories = System.IO.Directory.GetDirectories(@"\"); Debug.Print("directory count: " + directories.Length.ToString()); for (int i = 0; i < directories.Length; i++) { Debug.Print("directory: " + directories[i]); } string[] files = System.IO.Directory.GetFiles(@"\SD1"); Debug.Print("file count: " + files.Length.ToString()); for (int i = 0; i < files.Length; i++) { Debug.Print("filename: " + files[i]); FileStream fs = new FileStream(files[i], FileMode.Open, FileAccess.Read, FileShare.None, 512); StreamReader sr = new StreamReader(fs); Debug.Print("contents: " + sr.ReadToEnd()); } } } }
Finally, the assemblies that I referred to are:
Microsoft.SPOT.Hardware Microsoft.SPOT.IO Microsoft.SPOT.IO.Native mscorlib SecretLabs.NETMF.Hardware SecretLabs.NETMF.Hardware.NetduinoMini SecretLabs.NETMF.IO System.IO
Let me know if this rings a bell. Otherwise I'll keep investigating, using a different SPI device, as I suspect that my problem is a SPI issue, not related to the MMC/SD module.
Thanks
JP