Showing results for 
Search instead for 
Did you mean: 

SD Write error some time , not stable

Associate III

Hi ,

   I made a STM32F405VGT6 board with SD card interface. The SD code is generated using STM32CUBEMX and FatFs middleware.

   The SD file write is not stable, it return error sometimes after calling f_write(). However, if I run the same code in uVision debug mode with SWD/ST-LINK connected, the f_write() became very stable.

   What could be the difference between with debug mode and without debug mode that causing f_write unstable ? I guess it may be caused by some hardware timing that is too fast without the debug mode. Where can I add delay in the code that simulate the timing of debug mode ?Thanks.



Accepted Solutions
Senior III

Writing to the SD card is associated with a large consumption, especially when erasing blocks. Most of the problems are associated with insufficient power supply of the card and insufficient blocking of the supply voltage. The problem may not manifest itself in debug mode, because the writes are slower and the capacitors in the power supply are enough to cover them.

Hi ONadr,

   Thanks for your prompt reply. Could you explain more about "insufficient blocking of the supply voltage" ? How can I increase blocking of the supply vpltage ? I can not catch the meaning of "blocking" for supply voltage. Thanks.


I mean the capacitors between the supply voltage (Vss-Vdd). They should be as close as possible to the power connection to the card. It serves to block the penetration of interference to and from the card through the supply voltage and to compensation consumption peaks. For SD, I would recommend a few 10uF in ceramic plus a few 100nF in parallel.

This is some good quality example 

Hi ONadr,

  Thanks. This did help a lot.