SD-Karte Initialisierung über SPI-Schnittstelle

Bekomme ich invalid response-codes von meiner SD-Karte (CMD8, CMD55, und CMD41).

Init-routine:

SDCS = 1; //MMC deaktiviert
SPI1CON1bits.SMP = 0;
SPI1CON1bits.CKE = 1;
SPI1CON1bits.MSTEN = 1;
SPI1CON1bits.CKP = 0;
SPI1STATbits.SPIEN = 1;

for(i=0; i<10; i++)
    SPI(0xFF);

//RESET
unsigned char rr=Command(CMD0,0);
SDCS=1; //MMC deactivated
/* OK response == 1 */

r = Command(CMD8,0); //Check voltage
SDCS=1;
/*
  esponse ==  0xC1 ?!?
*/

r = Command(CMD58,0); //READ_OCR

unsigned char ocr1 = SPI(0xFF);
unsigned char ocr2 = SPI(0xFF);
unsigned char ocr3 = SPI(0xFF);
unsigned char ocr4 = SPI(0xFF);
unsigned char ocr5 = SPI(0xFF);

/*
  r = 0xF8; ?!?
  ocr1 = 0x0F;
  ocr2 = 0xFF;
  ocr3 = 0xFF;
  ocr4 = 0xFF;
  ocr5 = 0xFF;
*/

SDCS=1;

//INIT
unsigned char rrr = 0;
i = 10000;
do
{
    rrr = Command(55,0); //Next is APP CMD
    SDCS = 1;
    if(r)
        break;
} while(--i>0);

/*
OK response == 1
*/

//APP CMD 41 with OCR = 0x0F??

Lesen Sie die response-codes in den Kommentaren.

Ist es möglich, den response-code CMD8 ist 0xC1? Bit 7 sollte auf 0 stehen, richtig?

Ist es ein hardware-Fehler?

Formatieren Sie den code das nächste mal.
Einige Karten grundsätzlich nicht unterstützen den SPI-Modus. Welche Karte Marke? Es ist eine echte Karte oder ein fake?

InformationsquelleAutor Ich | 2010-05-17

Schreibe einen Kommentar