Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 
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;
                                }

If the card responds to CMD8, the response of ACMD41 includes the CCS field information. CCS is valid when the card returns ready (the busy bit is set to 1). CCS=1 means that the card is a High Capacity SD Memory Card.
CCS=0 means that the card is a Standard Capacity SD Memory Card

1. OCR register
The 32-bit operation conditions register stores the VDD voltage profile of the card. Additionally, this register
includes status information bits. One status bit is set if the card power up procedure has been finished. This register
includes another status bit indicating the card capacity status after set power up status bit. The OCR register shall be
implemented by the cards. The 32-bit operation conditions register stores the VDD voltage profile of the card. Bit 7 of
OCR is newly defined for Dual Voltage Card and set to 0 in default. If a Dual Voltage Card does not receive CMD8, OCR
bit 7 in the response indicates 0, and the Dual Voltage Card which received CMD8, sets this bit to 1.
Additionally, this register includes 2 more status information bits. Bit 31 - Card power up status bit, this status bit is
set if the card power up procedure has been finished. Bit 30 - Card capacity status bit, this status bit is set to 1 if card is
High Capacity SD Memory Card. 0 indicates that the card is Standard Capacity SD Memory Card. The Card Capacity
status bit is valid after the card power up procedure is completed and the card power up status bit is set to 1. The Host
shall read this status bit to identify a Standard or High Capacity SD Memory Card.
The OCR register shall be implemented by the cards.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top