求助:SD卡读写程序 初始化进入复位循环就出不来了,一直不返回0x01。。。

2019-03-24 15:03发布

//SD卡初始化
char SD_init(void)
{
  int i;
  int time=5;
  unsigned char response1=0xff,response2=0xff;
  P5SEL|=0X0e;   //初始化430UART引脚   P5DIR|=0X0B;   SPI_init();
  CS_1;
   do
  {
    if(!time)
      return (failed);
    time--;
   for(i=0;i<10;i++)
     Sendbyte(0xff);//延时80个CLK
     CS_0;
     Sendcmd(cmd0,0,0x95);
  }
   while(getresponse1()!=0x01);
     while((response1!=0x01)||(response2!=0x00))
    {
      CS_1;
      Sendbyte(0xff);//延时8个CLK
      CS_0;
      Sendcmd(cmd55,0,0xff);
      response1=getresponse1();
      CS_1;
      Sendbyte(0xff);
      CS_0;
      Sendcmd(acmd41,0,0xff);
      response2=getresponse0();
    }
  CS_1;
  Sendbyte(0xff);
  return (SUCCESS);
}       刚开始做430,要做个SPI方式写SD卡的程序,大侠们帮帮忙看看吧。。。这个问题已经纠结好久了 ,看了很多资料也没明白为什么循环不出来 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
15条回答
wstt
2019-03-25 12:10
还在看

一周热门 更多>

相关问题

    相关文章