cancel
Showing results for 
Search instead for 
Did you mean: 

SD Card in SPI Mode (byte alignment problem)

chrisw
Associate II
Posted on November 17, 2004 at 10:14

SD Card in SPI Mode (byte alignment problem)

2 REPLIES 2
chrisw
Associate II
Posted on November 15, 2004 at 08:04

Is there anyone who you help me with a problem I'm having writing a proprietary software interface to an SD card.

I'm trying to read/write the a SD card in SPI mode, but I keep getting byte misalignment in the responses to SPI commands.

For example, if I send CMD0 (40 00 00 00 00 95) to put the card into SPI mode, I sometimes get back 0xff 0x1 0xff, which is correct, but sometime I get 0xff 0xC0 0x7f 0xff, and other spuriously misaligned responses. The alignment also seems to vary each time the device is selected (/CS).

And sometimes I find that I can't select SPI-bus operation!!!

I'd be grateful of any help.

Regards

chrisw
Associate II
Posted on November 17, 2004 at 10:14

Many thanks to anyone who's looked at this and given it a second thought - but (I think) I've managed to fix my problem. And for anyone interested, you need to set CPOL = 0 and CPHA = 0, and to continually send the MMC_GO_IDLE_STATE command (after sending 4 sets of 0xFFs) until the SD card is fully in SPI mode with a response of 0x1. After this you're ready to go, and can poll the MMC_GO_IDLE_STATE status busy flag.