This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SD Card using SPI will not get out of idle state

I am trying to access the SD card on the TMS570LS12x_HDK development board.  (I am running a 400KHz spi clock that is high when not pulsing and have also ran it low when it is not pulsing)  I can access the SD card but I cannot get it out of the  idle state.  I have read most, if not all of the threads on this topic, but they all seem to direct you to threads that also do not have an answer to this.  I believe that I am using the recommend way of accessing the SD card from the protocol data sheets, but I must be missing something here is what I have tried:

    1. Tried the recommend way

             A. 80 clock pulse with SIMO at 0xFF and CS0 high.

             B. Sent CMD0 received 0xFF 0x01 ( which is expected and correct. I do have the CRC of 0x95)

             C. Sent  CMD55 received 0xFF 0x01

              D. Sent ACMD41 received 0xFF 0x01

              E. looped through C and D, but always got 0x01. (it is expected that the idle bit would clear eventually, but it did not.  I have left it running for several minutes)

     2.  did #1 above, but replace B and C with CMD1 and got the response of 0x01 (idle bit set) as I looped with this one command.

     3.   did #1 above  modifying  A so that CS0 was low (active) and got same result

     4.   did #1 above with a non-existing command between B and C.  The response to this command was 0xFF 0x05 (bad command bit set along with the idle bit).  The other command still responded with 0xFF 0x01

     5.   did #1 above with and added 80 clock pulses with SIMO at 0xFF and CS0 high between the A, B, C and D.  Still get the same responses.

     6. I have also tried putting a delay after the 80 clock pulses, and at other places so I am not banging it too fast.

Here is the data I am using for the commands:

    CMD0 = 41, 00, 00 ,00, 00, 95 (all hex)

    CMD55 = 77, 00, 00, 00, 00, xx

    ACMD41 = 69, 00, 10, 00, 00, xx  and have used  69, 00, 00, 00, 00, xx

I am using a new 4G SanDisk micoSD card that reads fine from my pc.

Does anybody know how to get this out of the Idle state?

  • I have added 0xFF to the end of all the commands since I read in some other blogs the SD card requires clock pulses with 0xFF for the input data so the SD card can perform it's internal task.  This just made is to that I get the 0x01 or 0x05 on the first byte when asking for a response.   I have also removed the 0x10 from the ACMD41 command.  I  am still getting 0x01 for responses.   

  • Don,

    I will take a look and come back to you soon.

    Regards,

    QJ

  • Thank you very much QJ,

    I have just about beat my brains out on this.  One thing I am not sure of is the arguments on the ACMD41 command.  Currently I am leaving this at 0's because I read somewhere that if you leave this argument at zero, it is like a universal acceptance of the current settings.  I have also verified that I am using mode 0, and I have moved my frequency slightly below the 400 KHz, which I measured with an Oscope and a logic analyzer.  I think it is odd that I can send a bad command and get the 0x05 back, but I cannot get the idle flag to clear.

    Looking forward to a solution

    Don

  • Don,

    If the SD card is initialized by CMD1 (you use 0x41) and the host treat it as MMC card, not SD card. For CMD55, CMD41, can you try to use the correct CRC not dummy CRC. I know the protocol says only CMD0 and CMD8 need CRC, but sometimes the SD card may violate the spec. 

    Regards,

    QJ

  • Hi QJ,

    I have tried the CMD1 (after the 80 clock pulses with the SIMO high, CS low and also with CS high), then followed with CMD1, and I just now tried it again.  The response is still 0x01.  It seems that the SD controller accepts the command, but does not clear the flag.  I have used the commands with and without CRC (I am using CRC values that were published at different sites), but I have not received a bad CRC flag in the response.  I have not tried the CMD8, but will later today.  The SanDisk SD Card Product Manual Verison2.2 indicates that CMD8 is reserved, and I am using a SanDisk micro SD card.

    Do you know where a good site is for calculating the CRCs so I can verify the values?  I have used several different sources to gathered information on the commands, but it would be nice to find someplace that just has a list of the commands and a list of the arguments.  In case anyone else is follow this thread, the best I have found so far, and in no particular order, are  http://alumni.cs.ucr.edu/~amitra/sdcard/Additional/sdcard_appnote_foust.pdf, http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General/SDSpec.pdf , and http://wiki.seabright.co.nz/wiki/SdCardProtocol.html 

    Thank you for your help

    Don

  • Eureka!  I found the problem.  I borrowed a 1G SanDisk card from a buddy, and the initialization works as expected.  The 4G SanDisk does not.  So, it seems that the 4G SanDisk I have does not work in spi mode (and I have tried all the different modes).  I got the 4G card from a computer store, it is bubble wrapped in a SanDisk package. So I does not appear to be a knock-off.   Examining the microSD card a little closer I see that it is marked with the number 4 in a circle (probably indicates a 4G) and then it also has an "HC" mark.   The microSD card adapter that came with it for PC access indicates there are three version "microSD"  "microSDHC" and "mocroSDXC"  

    After a little search I see that HC stands for High Capacity, and XC stands for Expanded Capacity.  They say these cards have more memory space than unmarked SD.  I wonder if they traded spi support for the  High or Expanded space.  I will have to look around to find some cards without these designation to see if they have spi access. However, right now I have to make up some time using the card that I can access.

    Don

  • Well, after some more extensive searching I am reading that the spi should work on the higher capacity devices with some different sequences, but since I took mine back, I cannot try these out.  I just wanted to note this in this thread so that my previous post won't throw someone off of pursuing these cards on spi.    I may come back to the higher capacity devices at a later date to see if I can get them to work.

  • Hi Don Meado,

       Something maybe helpful to you  which can be found here:

       http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/206181/995168.aspx#995168

    Regards,

    gagmeng