SD卡读扇区前127个可以读后面的不能读问题

[复制链接]
1007|1
 楼主| 拿起书本 发表于 2014-9-8 21:34 | 显示全部楼层 |阅读模式
SD卡, TE, se, ck, ui
各位兄弟姐妹们,能不能帮我一个忙啊,小弟在用SPI读SD卡式,出现一个问题,前面的127个扇区可用正常读写,但是128及以后的扇区就不能读写了,不知道为什么啊!
ret=SD_Rd_Block(DBUF, 128);
返回值是255
源程序如下,请教高人指点啊!  先谢谢了!
byte SD_Rd_Block(Uint16 *buff, unsigned long address)
{
        Uint16 count;
        //Block size is 512 bytes exactly
        //First Lower SS
        byte resp;
        SD_Assert();
        //Then send write command
        SD_Wt_Cmd(0x11,address<<9,0xff);
        resp=SD_Rd_Resp();
        if(resp!=0)
        return resp;
        //command was a success - now send data
        //start with DATA TOKEN = 0xFE
        while(SD_Rd_Byte()!=0xfe);

        for(count=0;count<128;count++)
        {
                *buff|=(Uint16)(SD_Rd_Byte()<<8);
                *buff|= (Uint16)(SD_Rd_Byte());
                *buff++;
                *buff|=(Uint16)(SD_Rd_Byte()<<8);
                *buff|=(Uint16)(SD_Rd_Byte());
                *buff++;
        }
        //data block sent - now send checksum
        SD_Rd_Byte();
        SD_Rd_Byte();
        //Now read in the DATA RESPONSE token
        SD_deAssert();//SD_CS=1
        SD_Rd_Byte();
        return 1;
        //printf("Command 0x11 (Read) was not received by the MMC.\n");
}

zhangmangui 发表于 2014-9-9 23:26 | 显示全部楼层
支持一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:好好学习,天天向上!

519

主题

4194

帖子

31

粉丝
快速回复 在线客服 返回列表 返回顶部