cmd的发送 mmc_求助:MMC卡初始化,发CMD0卡回01,但是再发CMD1回的还是01啊不该是回00的吗...

char SD_Init(void)

{

unsigned char retry,temp;

unsigned char i,in;

retry=0;

SPCR = (1<

//mmc的SPI时SCK钟频率小于400KHZ

//20110421MMC兼容SPCR = (1<

SFIOR|=0B00000100;//PUD置位

SPCR&=0B01111111;//SPIE=0;

SPSR |= (1<

for(i=0;i<0x0f;i++)

{//16*8

Write_Byte_SPI(0xff);    //1.send 74 clock at least!!!

}

Clr_Bit(SD_PORT, SD_CS_PIN);//~SD_CS_PIN;       //SD卡使能

//;//delay();   //Wait SD/SD ready...

retry=0;

do

{

temp=SD_Write_Command(0,0);//3.Send Command CMD1 to SD/SD-Card

retry++;

if(retry==10)

{

//LCD_Show_String(0,0,"     SD Init  3 ");

//LCD_Show_String(1,0,"    CMD1 Error! ");;//CMD1  Error!

retry=0;

}

}

while(temp!=01);

do

{ temp=SD_Write_Command(55,0);

temp=SD_Write_Command(41,0);//3.Send Command CMD1 to SD/SD-Card

i=0;

retry++;

if(retry==100)

{ //发了100次无回应,很可能不是SD卡而是MMC卡

retry=0;

do

{

i++;

temp=SD_Write_Command(1,0);

}while(temp!=0x00);

goto out;

}//if

} while((temp!=0)&&(i<101));//回应该是00

out:

//缺省块长度定义在CSD寄存器内(512字节)

return(0); //All commands have been taken.

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值