注册 登录
电子工程世界-论坛 返回首页 EEWORLD首页 频道 EE大学堂 下载中心 Datasheet 专题
nothingo的个人空间 https://home.eeworld.com.cn/space-uid-346377.html [收藏] [复制] [分享] [RSS]
日志

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

已有 912 次阅读2011-8-8 10:21

//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卡的程序,大侠们帮帮忙看看吧。。。这个问题已经纠结好久了 ,看了很多资料也没明白为什么循环不出来

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

热门文章