2020-04-27 12:59 AM
char data[] = "Testing File";
if(f_mount(&fs, SD_Path, 0) == FR_OK)
{
if(f_open(&myFile, "Test_File.txt", FA_WRITE | FA_CREATE_ALWAYS) == FR_OK)
{
if(f_write(&myFile, data, sizeof(data), &myBytes) == FR_OK)
{
f_close(&myFile);
}
f_close(&myFile);
}
}
2020-04-27 01:45 AM
I wouldn't close the same handle twice.
Validate the DISKIO layer works properly.
Inspect the FATFS code to see what structure was giving the error.
If using local variables, make sure they are cleared and that you have sufficient stack space so things don't get corrupted.