# microSD Class 4 card in SPI mode returns 0x000000021F after CMD8

I am trying to read an microSD card through an unbranded SD slot and a Basys3 FPGA. The microSD card, Kingston microSD HC 8GB Class 4, is used via an SD card adapter, also Kingston.

I am having trouble with getting past CMD8 of the initialization process. After I sent CMD0 it responded with 0x01 which is normal. After CMD0 I sent the CMD8 command; it responded with 0x000000021F. I wasn't able to find anything related to this code in any documentation.

To test, I tried using a SanDisk Ultra SDHC 32GB Class 10 with the same code. It successfully initialized.

Other things I have tried:

• Always / Not Always Sending SCLK.

Waveforms

The first one shows all of the initialization process. SD_CD is Card Detect (Active Low) and SD_WP is Write Protect (Active Low). SD_CLK is running at 390 kHz, 256 times slower than _cpuClock. Please note that the SD_MISO, SD_CD, SD_WP and _cpuClock are all simulated manually (i.e. doesn't receive any signal from the SD module). After card is detected, 1 millisecond is waited, followed by 74 SD_CLK's.

The second image is a zoom in of CMD0 and its response.

The third image is a zoom in of CMD8 and its response.

The final image is a zoom in of CMD55 and its response.

Update 1 (Prior to @Annoymous Answer) I managed to get my hands on a couple more cards. After testing it seems that only SanDisk Class 10 SDHC (both SD and microSD) returns an initialization finished state. The Kingston Class 4 SDHC SD returns a timeout after CMD0 while the Kingston Class 4 SDHC microSD returns a 0x000000021F. Changing the adapter made no difference in all cases. In the image below, the successful ones are in green and the unsuccessful ones are in red.

Update 2 (Response to @Annoymous Answer) After changing MOSI from posedge to negedge, the Kingston Class 4 SD card seems to initialized (which was previously timeouted). However, the Kingston Class 4 microSD card still respondsed with 0x000000021F.

• Both are SDHC, right? Are they both capable of the same class of operation? Sounds like the adapter is the difference. Any other adapters handy? – jonk May 21 '17 at 20:49
• Do you send enough dummy clocks prior to initialization? – JimmyB May 21 '17 at 21:00
• @JimmyB I sent 74 clocks prior to initialization. I will update my answer with the simulated waveform. – krismath May 21 '17 at 21:04
• @jonk I updated the class of each of the cards. Does class effects operation? I know that there are SDv1 and SDv2, but I am not aware how this is related to Class 4/Class 10. Regarding your other question, no other adapters are available. – krismath May 22 '17 at 11:26
• @krismath I wish I were expert in any of this, but unfortunately I'm not. You probably know a fair bit more than I do. But sometimes it helps to hear someone else's thoughts and questions when tracking something like this, so I offered a few that came to mind. That's about my limit, though, without spending a lot more time getting up to speed. – jonk May 22 '17 at 17:52

• Actually the CMD8 response was manually simulated -- this wasn't the actual SD's response. I will try what you suggested. Thanks! – krismath May 22 '17 at 9:53
• Thanks, more cards seems to have initialized after posedge is set to negedge. More dummy clocks are next in list! – krismath May 22 '17 at 11:56
• Unfortunately, after giving it more dummy clocks and setting CS according to you answer, the SD card still responds with 0x000000021F – krismath May 22 '17 at 18:48