建议你仔细看下ST的SDCAR.C 和SDIO的例子,再看下SD_ReadBlock和SD_ReadMultiBlocks的区别,看你前面的代码只用了SDIO_READ_SINGLE_BLOCK模式,我想你该再试下SDIO_READ_MULT_BLOCK模式,要想再提高速度,SD_ReadMultiBlocks是必须的。不好用很多时候是不会用,ST的SDIO很好用,我们的一个SDIO设备跑到36M都没有问题(更高的速度没试)。你可以再具体分析下速度到底是慢在SDIO上还是USB上。我前面的LOG信息是用的SDCARD.C的函数在FATFS下的测试结果。没有通过USB. 附上我的测试代码:
#define BUFSIZE 512*4
#define FAT_READ_TEST
#define FAT_WRITE_TEST
void FatFS_Test()
{
// FILINFO finfo;
UINT len,wlen;
UINT bufsize=1024;
DWORD tlen,maxsize;
u8 name[32];
u32 i;
u8 k;
test:
#ifdef FAT_READ_TEST
fr = f_open(&fp,"test.bin",FA_OPEN_EXISTING | FA_READ);
if(fr != FR_OK)
{
printf("\r\nopen file fail!");
return;
}
printf("\r\nRead File %d bufsize=%d",fp.fsize,bufsize);
//printf("\r\nFileSize:%Ld\r\n",fp.fsize);
tm_count=0;
SysCount(1);
tlen=0;
while(1)
{
fr = f_read(&fp,buf,bufsize,&len);
if(fr != FR_OK && len==0)
{
printf("\r\nread from file fail!");
break;
}
else
{
}
//USART_SendData(USART1,'.');
if(len<bufsize) {break; }
}
tm = SysCount(0);
f_close(&fp);
printf("\r\n Read bufsize=%d %d/%d = %4.3f MB/S\r\n",bufsize,fp.fsize, tm,(float)fp.fsize/(tm) );
#endif
#ifdef FAT_WRITE_TEST
tm_count=0;
SysCount(1);
tlen=0;
maxsize = 8*1024*1024L;
//bufsize = 1024;
//for(i=0;i<bufsize;i++) (u8)buf[i]=i;
sprintf((char *)name,"WRA_%d.bin",bufsize);
fr = f_open(&fp2, (const char *)name, FA_CREATE_ALWAYS | FA_WRITE);
if( fr != FR_OK)
{
printf("\r\nCreate File Failed");
}
else
printf("\r\nCreate File OK!");
len = bufsize;
k='A';
while(1)
{
memset(buf,k++,len);
fr = f_write(&fp2,buf,len,&wlen);
if( fr != FR_OK)
{
printf("\r\nWrite File Failed!\r\n");
break;
}
else
{
tlen +=wlen;
if(tlen>=maxsize) break;
}
}
tm = SysCount(0);
//printf(".");
printf("\r\n Write bufsize=%d %d/%d = %4.3f MB/S\r\n",bufsize,maxsize, tm,(float)maxsize/(tm) );
f_close(&fp2);
#endif
if( bufsize>=16384) { printf("\r\n FatFS Test OK!"); return; }
else
{
bufsize=bufsize<<1;
goto test;
} |