Electronic – Sandisk SDHC Card Responding with Illegal Command to CMD8 by SPI

sdspi

I was trying to initialize a Sandisk Micro SD card, High Capacity, using SPI. CMD0 returns 0x01, which is good. But then CMD8 returns 0x05 as the first 8 bits received, indicating an illegal command, which doesn't make sense because this is SDHC.

I did the following (The clock is at 200kHz. Data is sent MSB first, Data is read MSB first).

  1. For 100 clock cycles: MOSI = 1; CS = 1
  2. Next 48 clock cycles: CMD0 is sent through MOSI with CS = 0: 0x400000000095
  3. Next 8 clock cycles: Read MISO line: 0x01
  4. Next 48 clock cycles: CMD8 is sent through MOSI: 0x48000001AA0F
  5. Next 8 clock cycles: Read MISO line: 0x05

I've tried substituting CMD58 in for CMD8 in those steps, and that returned a legal command, so I don't think it is a timing issue. But I can't think of a reason why it would return an illegal command error for CMD8 when this card is SDHC. Can anyone help me with this issue?

Best Answer

According to the CRC7 calculation algorithm, CRC of 48000001AA should be 87 (43*2+1) and not 0F. You setting CRC7 wrong is the cause of Illegal command error.