Skip to main content
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
  • 719 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

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