zlj644 发表于 2010-8-2 20:57:59

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

各位兄弟姐妹们,能不能帮我一个忙啊,小弟在用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");
}

zlj644 发表于 2010-8-2 21:09:11

哎,发帖从来没被人回过,杯具啊

zlj644 发表于 2010-8-3 08:46:43

结帖,不问了,呵呵,自己解决
页: [1]
查看完整版本: SD卡读扇区前127个可以读后面的不能读问题