Skip to main content
SPARV.1
Visitor II
April 27, 2020
Question

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.

  • April 27, 2020
  • 1 reply
  • 730 views

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

  }

 }

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
April 27, 2020

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..