|
6#

楼主 |
发表于 2015-6-1 14:01:04
|
只看该作者
本帖最后由 lushidegreen 于 2015-6-1 14:09 编辑
我把USB_DEV_MSC例程中的disk_read()和disk_write()函数改成了如下内容:
Uint32 MMCSD_disk_read(void * pvDrive, unsigned char *pucData, unsigned int ulSector, unsigned int ulNumBlocks)
{
Uint32 res = 0;
res = SDMMC_MEM_readBytes ( hSDMMCMemInfo, ulSector *512, ulNumBlocks * 512, pucData);
return res;
}
Uint32 MMCSD_disk_write(void * pvDrive, unsigned char *pucData, unsigned int ulSector, unsigned int ulNumBlocks)
{
Uint32 res = 0;
Uint32 i;
for (i = 0; i < ulNumBlocks; i++) {
res = SDMMC_MEM_writeBytes ( hSDMMCMemInfo, (ulSector + i) * 512, 512, &pucData[i * 512]);
UTIL_waitLoop(100000);
UTIL_waitLoop(100000);
UTIL_waitLoop(100000);
}
return res;
}
其中有一个问题,SD卡写块函数不能调用SDMMC_MEM_writeBytes() 进行连续写,而且在每个块直接需要加入UTIL_waitLoop(100000);延时,而且不能少于3个100000。因为这个原因,所以SD卡写的时候很慢。
另外一个问题是,只能使用创龙配的8G SD卡,用其它卡的时候只能正常读,写入则会导致SD卡文件系统崩溃。用常用的正常读卡器插入,PC无法正常读取文件。用WinHex查看,发现DBR扇区已经被非法修改。
我想问一下,这两个问题是什么原因造成的?{:soso_e132:}{:soso_e132:} |
|