F_write of fatfs: so slow
Posted: Mon Feb 26, 2018 11:08 am
I did a configuration on sd_card example:
Using fatfs library instead of new_lib library to handle file. the code is very simple: continuously write down sd card until PIN_25 is grounded. I measured the duration of writing(by cell phone) is 6 secs, meanwhile the size of text file"r" in SD card is 8kB in other words, writing speed is lower than 2 kb/sec!!!!!!!!!
Any mistake i could improve?
Code: Select all
int iOk,iCount;
FIL iHandle;
f_unlink((const TCHAR*)"/demodir/r.txt");
iOk=f_open(&iHandle,(TCHAR*)"/demodir/r.txt",(BYTE)(FA_CREATE_NEW|FA_WRITE));
gpio_pad_select_gpio(25);
gpio_set_direction(25, GPIO_MODE_INPUT);
gpio_set_pull_mode(25, GPIO_PULLUP_ONLY);
while(1)
{
//printf ("\niok is %d",iOk);
iOk =f_write(&iHandle,"1",1,(UINT*)&iCount);
//printf ("\niok is %d",iOk);
printf ("\niok is %d",iCount);
//vTaskDelay(1000 / portTICK_RATE_MS);
if(gpio_get_level(25) == 0) break;
}
iOk=f_close(&iHandle);
Any mistake i could improve?