SD card initialization

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

Freya
Posts: 58
Joined: Mon Jun 11, 2012 11:57 am

SD card initialization

Wed Jul 09, 2014 12:49 pm

Hi to all,
I am trying to interract with SD card using SPI interface, but I got something wierd and I don not know what do now.
I am testing 3 cards (2GB, 4GB and 16GB) and I got the following responses:

CMD0
2GB -> 0x01
4GB -> 0x01
16GB -> DF // Do I should worry???

CMD8
2GB -> 05 FF FF FF FF // Version <2.0
4GB -> 01 00 00 01 AA // OK
16GB -> C1 7F FF FF FF // what does it mean? Versione <2.0?

CMD58
for all cards -> 01 00 80 00 FF

CMD1
2GB -> 00 // card should be OK
4GB -> 01 // Card should be KO
16GB -> 01 // Card should be KO

if I use ACMD41 instead of CMD1 I got:

ACMD41
2GB -> FF FF FF FF FF
4GB -> FF FF FF FF FF
16GB -> FF FF FF FF FF

I use the following code:

Code: Select all

	sp->SpiSetSpeed(200);	// Set speed at 200 KHz
	pioa->PIO_SODR = SDSS;	// Set Slave Select high
	for(i=0;i<10;i++) sp->SpiWriteByte(0, 0xFF, 0, 1);	// Send 80 (minimun 74) clock pulses for SD initialization
	
	pioa->PIO_CODR = SDSS;	// Set Slave Select low
	t = CommandAndResponse(CMD0, 0);	//GO_IDLE_STATE (Software reset)
	myio.PrintString((uint8_t *) "SD CMD0", ' ', 0);	// print response for degub
	myio.PrintHex(t, '\n');
	
	sp->SpiWriteByte(0, 0xFF, 0, 1);
	SendCommand(CMD8, 0x000001AA);	//SEND_IF_COND
	myio.PrintString((uint8_t *) "CMD8", ' ', 0);
	ReadResp7();	// read and print response for debug
	
	sp->SpiWriteByte(0, 0xFF, 0, 1);
	SendCommand(CMD58, 0x00000000);	//READ_OCR
	myio.PrintString((uint8_t *) "CMD58", ' ', 0);
	ReadResp7();	// read and print response for debug
	
	
	i=0;
	do 
	{
		t = CommandAndResponse(CMD55, 0x00000000);	//APP_CMD
		myio.PrintString((uint8_t *) "SD CMD55", ' ', 0);	// print response for degub
		myio.PrintHex(t, ' ');
		myio.PrintString((uint8_t *) "SD ACMD41", ' ', 0);
		SendCommand(ACMD41, 0x50000100);	//SEND_OP_COND (Initiate initialization process)
		ReadResp7();	// read and print response for debug
	}
	while((t!= 0) && (i++ <15));
	
	pioa->PIO_SODR = SDSS;	//Set Slave Select high
	
	sp->SpiSetSpeed(2461);
	return 0;
}

Do cards works properly?
Why 16GB return 0xDF? Is it correct?
On a Pc all cards are readable and writable, so they should not be broken

Is this the right forum? If not where can I ask for?

Thank you
Freya
Attachments
Immagine.png
Immagine.png (6.24 KiB) Viewed 5993 times

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 2 guests