AnsweredAssumed Answered

sync function hangs when using FATFS with SDHC - K70

Question asked by dachancellor on Jan 25, 2013
Latest reply on Apr 11, 2014 by Erich Styger


I am having an issue when using FATFs with a micro 4gb SDHC card and my K70 tower board.

I wrote a basic test program with the help of Erich's wonderful blog at .


My card is preformatted to FAT32.


My program does the following:

1. ensures that a card is inserted

2. mounts the card

3. opens a file

4. writes a test string

5. closes the file


My issues occurs on the final step, and I have traced it back to the sync function hanging.

(this occurs if sync is called manually, or when it is called from the action of closing the file)


It appears to spin forever in the SD_Wait function called from the disk_ioctl function passing the CTRL_SYNC command.

This indicates that SD->Finished is not being set AND a timeout is not occurring.


If I pull the card and put it in my PC, the file is in the root directory as expected, with the test string.

Any ideas on what may be causing this hang or how to fix it ?

It is reassuring that the files exist correctly on the card, as this should indicate that the rest of the code is working okay.