Wednesday, February 13, 2013

The mysterious SD card "CRC status response"

So I tried writing to the SD card.  I tried writing a continual byte value of 0xA5 (10100101b) so that the bits on data line 0 and data line 1 would alternate with each other.

A quick visual check showed that I was capturing this properly.


But wait.. what is that schlop right after the CRC on data line 0??  I was expecting the line to go low (busy) and then high again.  But it looks like there is another type of response.

A scouring of the SD card simplified specs revealed to me that after write operations, the SD card sends a "CRC status response" followed by a "busy" signal (holding the line low while it is busy writing).  The trouble is, the specs do not seem to define this response anywhere!  They just say unhelpful remarks like "see below" or "see elsewhere.

I finally decided to try my luck inside the SPI section of the specs, even though I am not using SPI mode.  And finally, in section 7.3.3.1, I found a section entitled "Data Response Token."  This does indeed seem to be what I am looking for.

Here is how it describes this token:

bit:
4 - always 0
3 - status
2 - status
1 - status
0 - always 1

010 - data accepted
101 - data rejected due to CRC error
110 - data rejected due to write error

As you can (hopefully) see in my screenshot, I am indeed getting the following bits: 01011, which corresponds with "CRC error."  And following that, I am seeing the data line being held low to indicate "busy".

So now, once I debug my CRC calculator defect, I should see 00101 (data accepted) followed by the line being held low (busy) while it writes.

On to debugging my CRC algorithm! (it works in my C code, just not VHDL!)

No comments:

Post a Comment