SD的初始化过程中,在送出CMD55后,回复的是0x01对的。但在送出ACMD41后,回复的确不是0x00.请帮我看看我的程序有什么问题吧,谢谢!
初始化程序如下:
//================================================================================================
//实现功能:初始化SD卡(参考SD卡初始化时序)
//================================================================================================
unsigned char SdInit(void)
{
unsigned char i,time=0;
unsigned char response=0x00;
//send CMD0,如果response=0x01则SD卡成功转到SPI模式
do
{
P1OUT |=0x80; //SD_CS=1;
for(i=0;i<=9;i++) //复位时最少写入74个时钟周期
SdWrite(0xff);
P1OUT &=0x7f; //SD_CS=0; 复位后CS拉低
SdCommand(0x00,0,0x95); //Send Command 0 to put MMC in SPI mode
response=SdResponse();
time++;
}
while((response!=0x01)&&(time<100)); //等待命令CMD0的响应
if(time==100)return 0; //100次仍然不能得到命令CMD0的响应,超时退出
//SD卡在进入SPI模式后,激活命令为Cmd55,ACmd41
do {
SdCommand(0x37,0,0xff);
response=SdResponse();
if (response!=0x01)
{
lcd_pos(4,0);
Disp_HZ("55失败",3);
return 0;
}
SdCommand(0x29,0,0xff);
response=SdResponse();
} while (response!=0x00);
//最后CS拉高
P1OUT |=0x80; //SD_CS=1;
SdWrite(0xff); //补偿8个时钟
return 1; //初始化成功,返回成功信号1
} |