cancel
Showing results for 
Search instead for 
Did you mean: 

i am using stm32f103xE MCU. i am using FATFS with SDIO. it's opening the file, but when i am writing the data to the file it's giving the FR_INVALID_OBJECT Error.

SPARV.1
Associate

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);

  }

 }

1 REPLY 1

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.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..