SD/MMC SPI Communication Debugging
The SD/MMC SPI driver accesses the hardware through a port (SPI BSP) as described in SD/MMC SPI Mode BSP. A new BSP developed according to MCU/MPU documentation or by example must be verified step-by-step until flawless operation is achieved:
- 1 Initialization. Initialization must succeed.
- 2 Read data. Data must be read from card, in both single- and multiple-block transactions.
- 3 Write data. Data must be written to the card, in both single and multiple-block transactions, and subsequently verified (by reading the modified sectors and comparing to the intended contents).
- Figure - SD/MMC SPI mode communication sequence
(1) When no data is being transmitted, DataOut line is held high.
(2) During busy signaling, DataOut line is held low.
(3) The CRC is the 16-bit CCITT CRC. By default, this is optional and dummy bytes may be transmitted instead. The card only checks the CRC if CRC_ON_OFF
has been executed.
The initialization process reveals that commands can be executed and proper responses are returned. The command responses in SPI mode are identical to those in cardmode (see Figure - Command responses (SD card) and SD/MMC SPI Communication Debugging), except each is preceded by a R1 status byte. Obvious errors, such as improper initialization or failed chip select manipulation, will typically be caught here. More subtle conditions may appear intermittently during reading or writing.