MCU=89C52,晶振=12MHZ
/**************************************************************
函数原型:void ini_sd(void)
功能: 上电后初始化SD卡
**************************************************************/
bit Ini_sd(void)
{
uchar temp=0,temp1=0;
bit bdata state=1;
sd_cs=1;
delay_1s();
Write_delay();
sd_cs=0;
do{
temp= Write_cmd(cmd0,0x00000000,0x4a); //发送CMD0
}while(temp!=0x01);
sd_cs=1;
Write_byte(0xff);
led_0=0;
do{
sd_cs=0;
while(Write_cmd(cmd55,0x00000000,0x32)!=0x01); ////发送CMD55
sd_cs=1;
Write_byte(0xff);
led_1=0;
sd_cs=0;
temp1=Write_cmd(cmd41,0x00000000,0xff); //程序死在这里
sd_cs=1;
}while(temp1!=0x00);
sd_cs=1;
Write_byte(0xff);
led_2=0;
state=0; |