I have been trying to use the SD Card on the MCB2300 with either the 2387 or 2388. In both cases, the example code for USB\Device\Memory_FlashFS\SD_FILE\Memory.uvproj and RL\FlashFS\SD_File projects, the SD card may or may not initialize correctly upon startup. Usually you get the message that it's not formatted, but that's just because the finit fails. However, this only happens every other time. If it works at startup, it will fail on reset, and then work again after a second reset. If it fails at startup, the next reset will make it work, etc. I traced it back to finit, but then I can't debug past that because I don't have source code (yet). I tried contacting Keil directly, but after numerous requests all I got was:
We've had some issues with the SD Card library letely. Please download and install v4.22, which may address some of them.
Let me know if you still have problems with the new version.
The new version worked the same way, which I reported, and I've heard nothing since. Has anyone else seen this behavior, and is there a workaround?
Try increasing the "DMA_TOUT" constant in the "MCI_LPC24xx.c" file. It may or may not help...
Try decreasing speed in driver it might be problematic because your layout, check if you have problems with power.
Neither suggestion had the desired effect. In MCI_LPC23xx.c I decreased the bus speed in BusSpeed() by redicing kbaud parameter (kbaud = kbaud/2) and I increased DMA_TOUT from 10000000 to 40000000. I also added a delay in Init after the MCI_POWER is turned on. It still fails every other time. Let me be clear, this is a straight out of the box MCB2300 with Keil's example, so I am complete vanilla here. This should work. Next?
SD card brand...? Industrial grade or not? Some manufacturer cause more trouble than others.
I had discounted that thought, but went ahead and tested. Sure enough, PNY (the one I've been using) fails but SanDisk works. That's a step in the right direction. Any notion of what can be done about this? I can put in the manual not to use cheap ass SD cards, but I really have no control over it, and I'm the one that will get the service call when it doesn't work.
I'm sorry - I cannot help you beyond what I suggested.
Stable power? Enough voltage?
Power to card applied early enough so voltage is stable before initialization?
From what I can tell, yes. I thought about initialization timing after reset as well, but that does not seem to be it, I've changed a bunch of timing in the code with no effect. The only other thing I can think of that's different is that the SanDisk card I'm using is full size, and the one that fails is actually a Mini-SD in an adapter. What's so strange is that it fails exactly every other reset. If it were just some timing on the edge, you'd expect to fail more or less randomly.
It also occurs to me that we may be looking under the wrong rock. It's not MCI initialization per se that's failing, but the file system finit. I started with the assumption that finit was failing because of an MCI system problem, but that's only an assumption.
Try also to put finger on the card while in slot, it might be a bad contact of slot with the board or card with the slot. Otherwise try another card to provide more information about where problem is.
What's so strange is that it fails exactly every other reset. something like this
if (a) { ...... ...... ...... a=0; } else { fail }
a good look at variables before and after ONE reset could be very revealing.
Erik
Try placing a breakpoint in the MCI driver itself whose source is provided. There, you can see where exactly in the init phase the failure occurs. "finit" invokes "mci_init".
Right idea, but I'm not sure I'm in the right place. In MCI_LPC23xx.c there's an Init routine, but it doesn't do anything conditional. It sets ports and always returns TRUE. However, there is a Command() routine, and in there I tracked it to MCI_CMD_TIMEOUT being thrown. I don't know if this is due to an earlier failure of some kind, I don't have the rest of the source. Changing the timeout itself doesn't seem to make a difference, so it's not a matter of timing as much as something has either confused or shut down the SD card so it's not responding.
Any solution to this problem? I am having the exact same thing. The SD card will work EVERY OTHER time but will fail EVERY OTHER time too.
Very strange behavior.