Hello,
I have interfaced an LPC-H2148 from Olimex to a Micro SD break out board from Sparkfun.
I use the SPI0 module on the LPC2148, since I already have assigned the SSP pins to other peripherals.
Here is the wiring description:
Micro SD <—> LPC2148
CS <—> P0.7 (GPIO output)
DI <—> P0.6 (MOSI0)
SCK <—> P0.4 (SCK0)
DO <—> P0.8 (MISO0)
On the Micro SD break out board, I have connected C0 to VCC (3.3V) using a 1M pull up resistor. Apparently this is to limit current consumption…
I am using a Micro SD card of 1G from SanDisk. I’ve checked the card is working, I can access it from a card reader using window.
I used AN10406 from NXP to generate code for communicating with the SD card. However, I had to update that code since the AN uses the SSP port, not the SPI.
I’ve modified the PINSEL0 register so it defines the SPI pins as active.
PCLOCK is 1/2 of CCLK.
I have checked the SPI peripheral is powered.
I’ve initialized the SPI control register so it is master, MSB first, CPHA = 0, CPOL = 0, as defined for the SSP module in AN10406. I only send 8 bits per transaction.
I used the same initialization sequence as used in AN10406, which consists of sending 10 dummy bytes to the card to initialize it in SPI mode, then send the 40 00 00 00 00 95 command (GO_IDLE_STATE).
As shown in the example, I set the SD CS before sending the dummy bytes, but clear it before sending the GO_IDLE_STATE command.
I’ve tried that sequence a different rates for the clock prescale register (minimum and maximum value).
From what I understand of the SPI protocol, the slave is supposed to mirror the bytes the master is sending. However, every time I send a byte (whatever the value is), SSPDR returns 0xFF. Eventually I never receive any answer from the card.
What am I missing???
Thanks!