Initialise SD/SDHC Card?

Status
Not open for further replies.

dktd3

New Member
First, I send CMD0, I receive R1 Respone --> ok
Then send CMD8 to detect SD or SDHC card with value : (0x48,0x00,0x00,0x01,0xAA,0x87). I receive R7 respone (0x01,0x00,0x00,0x01,0xAA) in both SD and SDHC --> so i dont detect type of card?
Anybody know why SD card return that value? Where did i make mistake???
Thank in advance
 

Per ELM - How to Use MMC/SDC they are both V2 cards. For a V1.*/MMC card you should get a illegal command response from CMD8.

C18 Code fragment for SD/SDHC detection
Code:
        if ( send_cmd ( CMD0, 0 ) == 1 ) {                          /* Enter Idle state */

                if ( send_cmd ( CMD8, 0x1AA ) == 1 ) {                      /* SDC Ver2+ */
                        for ( n = 0; n < 4; n++ ) ocr[n] = rcvr_spi ();       /* Get trailng data of R7 resp */
                        if ( ocr[2] == 0x01 && ocr[3] == 0xAA ) {                  /* The card can work at vdd range of 2.7-3.6V */
                                send_cmd ( CRC_ON_OFF, 0 ); // no checking CRC, redundant
                                while ( send_cmd ( ACMD41, 1UL << 30 ) ); /* ACMD41 with HCS bit */

                                wdttime ( SDTIME ); // wait for card to init
                                SSP1CON1 = SSP1CON1 & 0xf0;       // set to full speed
//                                                              SSP1CON1bits.SSPM0=1;                                                   // set to fosc/16
                                if ( send_cmd ( CMD58, 0 ) == 0 ) {              /* Check CCS bit in the OCR */
                                        for ( n = 0; n < 4; n++ )
                                                ocr[n] = rcvr_spi ();
                                        SDC0.sdtype = ( ocr[0] & 0x40 ) ? 6 : 2;
                                }
                        }
                } else {                      /* SDC Ver1 or MMC */
                        if ( send_cmd ( ACMD41, 0 ) <= 1 ) {
                                SDC0.sdtype = 2;
                                cmd = ACMD41;     /* SDC */
                        } else {
                                SDC0.sdtype = 1;
                                cmd = CMD1;       /* MMC */
                        }
                        while ( send_cmd ( cmd, 0 ) );    /* Wait for leaving idle state */

                        if ( send_cmd ( CMD16, 512 ) == 0 );  /* Select R/W block length */
                }
 
Last edited:
Thank for your reply.
In the older versions, my froject only support SD/MMC card. In the function to initialise card, I use CMD0 -> CMD41 -> CMD1. It work ok with my SD Card.
Now, I upgrade to support SDHC. But when I send CMD8, both SD and SDHC return the same valid value (0x01,0x00,0x00,0x01,0xAA).
Thank you.
 
Are you checking that the CMD8 was executed by the SD card by reading the R1 response token?

**broken link removed**
 
Yes.
I receive 5bytes (R7 respone) at the same time.
The first byte is R1 respone = 0x01;
The next 4 bytes is 0x00,0x00,0x01,0xAA.
 
Yes.
I receive 5bytes (R7 respone) at the same time.
The first byte is R1 respone = 0x01;
The next 4 bytes is 0x00,0x00,0x01,0xAA.

What is the R3 response token from a CMD58?

**broken link removed**

Code:
                                if ( send_cmd ( CMD58, 0 ) == 0 ) {              /* Check CCS bit in the OCR */
                                        for ( n = 0; n < 4; n++ )
                                                ocr[n] = rcvr_spi ();
                                        SDC0.sdtype = ( ocr[0] & 0x40 ) ? 6 : 2;
                                }


 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…