unsigned char SD_Reset()
{
unsigned char time,temp,i;
unsigned char pcmd[] = {0x40,0x00,0x00,0x00,0x00,0x95};
is_init=1; //is_init置为1,让SPI速度慢下来
SD_CS_HIGH;
for(i=0;i<0x0f;i++) //初始时,首先要发送最少74个时钟信号,这是必须的!!!
{
SD_spi_write(0xff); //120个时钟
}
SD_CS_LOW;
time=0;
do
{
temp=SD_Write_Cmd(pcmd);//写入CMD0
time++;
if(time==TRY_TIME)
{
return(INIT_CMD0_ERROR);//CMD0写入失败
}
}while(temp!=0x01);
SD_CS_HIGH;
SD_spi_write(0xff); //按照SD卡的操作时序在这里补8个时钟
return 0;//返回0,说明复位操作成功
}
我的复位程序如上所示 ,但每次DO上的返回值都是00h 给DO加上拉电阻后 返回值编程FFH (不知道需要加上拉电阻不?)
是复位时序有问题 还是板子有问题?
一周热门 更多>