Durante días trabajé en esto y no tengo solución. Mi ACMD 41 devuelve constantemente 0x01. Aquí está mi código. ¿Puede alguien ayudarme con esto? Realmente necesito a alguien que haya trabajado en esto.
char micro_SD_Init()
{
//raise CS and MOSI for 80 clock cycles
//SendByte(0xff) 10 times with CS high
int i;
__delay_cycles(500);
// Init SPI Module
SPI_init();
/* Enable CS bit for using */
P3DIR |= BIT0;
//initialization sequence on PowerUp -> 80 clock cycles delay
CS_HIGH();
for(i = 0; i < 10; i++)
{
SPI_Send_Byte(DUMMY_CHAR);
}
CS_LOW();
SPI_Send_Byte(DUMMY_CHAR);
SPI_Send_Byte(DUMMY_CHAR);
//Send Command 0 to put microSD in SPI mode
micro_SD_SendCmd(MICROSD_GO_IDLE_STATE,0x00000000,0x95);
while (resp1 != 0x01) // resp1 != 0x01
{
SPI_Send_Byte(DUMMY_CHAR);
micro_SD_SendCmd(MICROSD_GO_IDLE_STATE,0x00000000,0x95); // CMD0
resp1 = micro_SD_GetResponse();
SPI_Send_Byte(DUMMY_CHAR);
}
SPI_Send_Byte(DUMMY_CHAR);
/* Send if cond */
while ((array_resp[0] != 0x01) && (array_resp[3] != 0x01) && (array_resp[4] != 0xAA))
{
micro_SD_SendCmd(MICROSD_SEND_IF_COND,0x000001AA,0x87); // CMD8
micro_SD_GetLongerResponse();
SPI_Send_Byte(DUMMY_CHAR);
}
/* prosla CMD8 */
CS_HIGH();
SPI_Send_Byte(DUMMY_CHAR);
CS_LOW();
/* Tell that the next command is aplication-specific command */
do
{
SPI_Send_Byte(DUMMY_CHAR);
micro_SD_SendCmd(MICROSD_NEXT_ACMD,0x00000000,0x65); // CMD 55
CS_HIGH();
__delay_cycles(50);
CS_LOW();
SPI_Send_Byte(DUMMY_CHAR);
//ACMD41
micro_SD_SendCmd(MICROSD_SEND_OP_COND,0x40000000,0x77);
resp1 = micro_SD_GetResponse();
if (resp1 == 0x00) break;
} while (resp1 != 0x00);
//SPI_speed_up();
//--------------------------------------------------
while (SPI_Send_Byte(DUMMY_CHAR) != 0xFF)
{
SPI_Send_Byte(DUMMY_CHAR);
}
// da provjerimo napon napajanja na kartici
SPI_Send_Byte(DUMMY_CHAR);
micro_SD_SendCmd(MICROSD_READ_OCR,0x00000000,0x75);
micro_SD_GetLongerResponse();
if ((array_resp[1] == 0xC0) || (array_resp[1] == 0x40))
printf ("SDHC kartica validna!");
else
micro_SD_SetBlockLength(512);
return (MICROSD_SUCCESS);
}