代码是用的M3-FATFS,只是修改了main.c文件。main()函数是这么写的:
int main(void)
{
int res;
FIL fdst;
FATFS fs;
UINT bw; // File R/W count
BYTE buffer[512]; // file copy buffer
CHAR Buf1 = 60;
CHAR Buf2 = 70;
int i;
f_mount(0,&fs);
res = f_open(&fdst, "0:/demo.txt", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
if ( res == FR_OK )
{
for(i=0;i<100;i++)
{
f_write(&fdst, &Buf1, sizeof(Buf1), &bw);
f_lseek(&fdst, fdst.fsize);
f_sync(&fdst);
f_write(&fdst, &Buf2, sizeof(Buf2), &bw);
f_lseek(&fdst, fdst.fsize);
f_sync(&fdst);
}
f_close(&fdst);
f_mount(0, NULL);
}
while (1){}
}
我用LED灯做的指示,写完所有数据后点亮,在上面写入200个8bit char变量的情况下需要1分钟左右。我用示波器量SD卡CLK引脚是24MHz,并且SD卡4个数据引脚都有信号,说明是开启了4bit模式的。SDIO+DMA+24MHz+4bit+SD_WriteMultiBlocks(),怎么会这么慢呢? |