# Sandisk SDHC Card Responding with Illegal Command to CMD8 by SPI?

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?

• You may want to try sending a couple of dummy clocks (with CS=1) after each command. – JimmyB Mar 4 '17 at 12:54

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.