Advice to Initialize SD on LPC2148

Started by Gaspar Pollano January 26, 2009
Hi Guys!

The past two days I was dealing with some strange behaviour on my
I use a LPC2148 conected to an SD-CARD (1GB Kingston) on the SP1
(SSP) port. The code I was using is EFSL (0.2.9 RC 7) on Yagarto

My Code is something like this:
1> Reset uC
2> Init peripherals (GPIOs, EEPROM, GLCDs, etc)
3> Some Beeps, Splash screen at GLCD, etc
4> Init SD

Being short, the SD initialize only one of many times, sometimes when
I "touch" de SD Socket (while the EFSL's sd_init function was trying
and trying), sometimes only when "she" wants.
All circuit is made on PCB (not protoboards), all pull-ups R's are
correct, soft checked, etc... So.. "what's the deal?"??

Searching on this forum, I found this:

(#19545 from user 'deliconn' Tue Sep 26, 2006)
If I initialize the SD card right away (first couple instructions in
my main) things work great. But if I stick a delay right before SD
initialization (just a spinning 'for loop') for anything over 100ms
the card will not initialize. I have tried many cards, so its not
card specific, and I am running my SPI bus at about 275KHz so that
should be slow enough. I do not have any power control from the LPC
to the SD card. When the LPC is powered, the SD is powered.

So, I decide to move the code of SD control pins (SPI1 pins)
initialization rigth after reset, and leaving the "real" init (SPI1
registers, SD comunication) for later.

Everything seems to works fine now! Maybe the SD card 'hang's up' if
their control pins (Chip Select mainly) aren't configured right after
VDD is ON.

Maybe this experience is useful to someone!


An Engineer's Guide to the LPC2100 Series