SD card error (FR_DISK_ERROR) with Chan's FATFS

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jan 13, 2017 by chakravarthi m
Content originally posted in LPCWare by arvind.k08 on Mon Aug 10 22:02:32 MST 2015

I am using SDcard via MCI interface on our custom board with LPC1778.
For read/write on SD card I am using Chan's Fatfs (v 0.10b).
SDcard used: Sandisk Ultra, 8 Gb, class 10

Here I am using SD card for data logging where it fails many times.
My requirement is to log data coming from another chip. I am writing data to the SD card every second.
The data to write is around 4000 bytes. I am writing these data in SDcard, But sometimes while writing [function: f_write()], it fails with FR_DISK_ERR frequently and further if I am trying to write it fails FR_INVALID_OBJECT.
It works only after I do f_close() and again f_open(), which is more addon to to code, I feel I might loose the data coming from another chip.

Please suggest a way how to handle these SD card errors, specially FR_DISK_ERR, so these errors should not come again and again so frequently. It has become a major block for my application.