本帖最后由 ildpj 于 2020-3-23 14:51 編輯
請問4G以上的sd卡,能用SPI驅動嗎? 我使用16G的sd卡,初始化一直沒有通過,前面的CMD0,CMD8,都能正常返回0x01,但就是ACMD41一直返回0x01,困惑了我好久,哪位大佬指點指點我,,,,謝謝
我用的51單片機模擬SPI驅動的,下面是復位的程序,大神幫忙看看
uchar SD_Reset()
{
uchar j,time=0,r1,time1;
cs=1;
SD_Delay=1; //降低速率
for(j=0;j<20;j++) //執行160時鐘
{
Write_Byte(0xff);
}
cs=0;
/*發送CMD0*/
do
{
r1=Write_Common(0,0x00000000,0x95);
time++;
if(time>=255)
{
cs=1;
Write_Byte(0xff);
return 2;
}
}
while(r1!=0x01) ; //正常
time=0;
/*CMD8*/
do
{
r1=Write_Common(8,0x000001AA,0x87);
time++;
if(time>254)
{
cs=1;
Write_Byte(0xff);
return 3;
}
}
while(r1!=0x01); //正常
table[0]=Read_Byte();
table[1]=Read_Byte();
table[2]=Read_Byte();
table[3]=Read_Byte();
sendBin(table[2]);
sendDate(' ');
sendBin(table[3]);
/*ACMD41*/
time=0;
time1=0;
do
{
do
{
r1=Write_Common(55,0x0000000,0xff);
time1++;
if(time1>200)
{
cs=1;
Write_Byte(0xff);
return 5;
}
}
while(r1!=0x01);
time1=0;
r1=Write_Common(41,0x4000000,0xff);
time++;
if(time>254)
{
cs=1;
Write_Byte(0xff);
return r1; //響應0x01,無法正常初始化
}
}while((r1!=0x00)); //???
cs=1;
Write_Byte(0xff);
SD_Delay=0;
return 0;
}
|