本帖最后由 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;
}
|