SD card interfacing

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by IanB on Wed Apr 09 10:02:53 MST 2014
I'm just starting to write the code to interface an SD card to the SPI port (of a LPC1114).

1) To match the SD card spec, it would appear that CPOL=0 and CPHA=0 to give the right clock edges and phases. I don't quite follow why SSEL has to be pulsed HIGH between each data frame. Could someone please explain.

2) After sending an SD Command, the SD card requires 8 dummy bits (with Din (that's MOSI) HIGH), and then for the Dout  line  (MISO) to be read ONE BIT AT A TIME until a zero appears indicating the start of the Response message.

Is there a way of reading MISO one bit at a time, other than taking control of the pins back from the SPI port and toggling SCKn manually?

I have looked at the code in various SD card drivers, and they read a whole byte from MISO. If this works how does it make sure that it aligns with the zero start bit?
It doesn't appear that the SD card spec guarantees any specific number of dummy clocks between the end of the command and the start of the response.