To replicate my setup you need:
- discovery (F407)
- Discover - M0 expansion "shield"
- Sd Card
- download my test project under atollic here (cube mx project included):
CubeMX_sdio_fat_sdkarta.rar | Ulož.to
In one of my projects i am trying to achieve to save data from mems microphone to .wav on sd card using FAT. It worked, but unfortunately, from time to time, when i try to write new chunk of data into the file, f_write() return me an error (FR_DISK_ERR).
To find the source of the issue i have made a new project, where i only setup sdio, FAT, push button and a timer that triggers writing of a new chung of dummy data into the sd card (file). (that simulates the stream of data from microphone). The issue occure sometimes on the 3rd write batch (button push), sometimes on 5th, ... It varies. With each new batch i open a new file with incremented number in its name so i can later observe with what number of file did the issie occured.
The procedure goes like this:
Program waits for blue button to be pushed
then program mouts the SD card (f_mount)
if(f_mount(&SDFatFs, (TCHAR const*)SD_Path, 0) != FR_OK)
then open a new file
f_open(&MyFile, FilName, FA_CREATE_ALWAYS|FA_WRITE) != FR_OK) new file
then comes the write while loop where i write new chunk of data every 2 ms or so
f_write(&MyFile, u8WriteBuffer, WR_BUFF_SIZE,(void *)&byteswritten);
and after the write of whole batch (2500 chunks of 176 B) is done, program waits for another button push ...
Can somebody give me some feedback on that? Where could be the problem? Do anyone faced same problem?
Thank you very much