cancel
Showing results for 
Search instead for 
Did you mean: 

Fatfs f_close causes idle hook

fakheri.ali
Associate II
Posted on April 09, 2018 at 08:38

Hello everyone

I use stm32f746 discovery board.

I implemented emwin,Free rtos and Fatfs for the SDcard(using SDIO interface).

In my application after pressing a button, a value(as a string) is saved in the SDcard.

Everything works fine.but after an unspecified time, pressing 'save button' makes the application

go to handle to the idle task(this function: void vApplicationIdleHook(void)) and about 30 seconds everything is stopped.

after this time f_close function returns FR_DISK_ERROR.

This happens exactly the moment disk_write function is executed.(disk_write in f_sync or f_close functions)

Is there a way to prevent this happening?

Any Help please ?

Thank you
2 REPLIES 2
Posted on April 09, 2018 at 16:08

I would avoid calling FATFS/SDIO from an asynchronous interrupt, the routines are unlikely thread-safe, and at the SDIO level need to have access serialized.

Suggest you flag a deferred operation, and keep the FATFS/SDIO code in a singular thread.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 10, 2018 at 05:55

Hello clive

Thanks for your fast reply.

I used just one thread that's why this problem is occured.

I have to add another thread for FATFS functions.I hope the problem is resolved.

But I can't understand what you mean by this '

flag a deferred operation

'.