Hi, I have seen the threads on SD card issues but none of them seem to have been satisfactorily completed. We have a device based on USBizi which has an SD card slot but we cannot get it to work.
The _storage = new PersistentStorage(“SD”); fails after about 2 seconds with a system.exception.
We are using Sandisk 2MB cards.
In our design we do not control the power to the SD card it is powered all the time.
We connect the SD card connector to the SD lines defined in the USBizi (100 pin) user manual. The card detect switch goes to IO4 (pin 70) If we remove the card the remove interupt is fired and if we insert the card the insert interup if fired.
Our code is:
private InterruptPort SdCardInterupt;
private PersistentStorage _storage;
//private StorageDevice _device;
// Note: A constructor summary is auto-generated by the doc builder.
/// <summary></summary>
/// <param name="socketNumber">The mainboard socket that has the module plugged into it.</param>
public SDCard()
{
// add Insert/Eject events
RemovableMedia.Insert += Insert;
RemovableMedia.Eject += Eject;
IsCardMounted = false;
SdCardInterupt = new InterruptPort((Cpu.Pin)USBizi.Pin.IO4, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
SdCardInterupt.OnInterrupt += new NativeEventHandler(SdCardInterupt_OnInterrupt);
try
{
if (IsCardInserted)
{
_storage = new PersistentStorage("SD"); //This line throws the error
MountSDCard();
}
}
catch (Exception e)
{
}
}
I have checked the power to the SD card and it is 3.15V (well within spec)
The IsCardInserted simply does a read on the IO pin
public bool IsCardInserted
{
get { return !SdCardInterupt.Read(); }
}
This code does correctly return true when a card is present
I have seen lots of examples but of course they all do exactly what we are doing in terms of software, if you can’t call the constructor then there isn’t much else you can do!!
What would be really helpful is to understand what the contstructor does that might throw the exception…does it for example actually try and communicate with the card?
We have a custom board as Brett said, we used the FEZMini as a reference, we have used all the same connections to the SD card connector
In implementing directly on USBizi we of course loose all concept of ‘sockets’ so I wondered if there was something we need to do to tell USBizi to condfigure the pins for SD card use?