I have a K64 in a commercial application which uses the SDHC to interface with a micro SD card.
The code for reading and writing sectors include several "while" loops waiting for flags to be set in the SDHC controller's register to identify completion of the operation.
On several SD cards (at customer not at my location) the SDHC code stalls waiting for a completion flag to be set -- which NEVER sets.
I have installed timout within these "while loop" code sections to break out after 25 millsecs without the flag being set.
My question -- what is the best/robust error recovery method which will result in completion if run again?
Right now -- I'm of the mindset the issue is with the SD card since I have replaced the CPU board and the same issue occurs.
The current recovery method I have employed is to trap the timeout error at the read/write block functions and force a SDHC initialization again (kick it in the head and do a SDHC reset and initialize the whole system again).
My current method seems like an extreme measure because it takes time to perform the initialization process which leads to the customer seeing/hearing the extended time.
I'm attempting recovery this way since I don't know a better way to correct the operational status of the SDHC or the SD card so the read/write operation can be attempted again and complete without error.
Any insights or comments - please tell.
Thanks.
Joe
Solved! Go to Solution.
Hi Joe,
I also checked the MCUXpresso SDK for K64 about SDCard application, which also using timeout to check error recovery condition. With the SDMMCHOST_TRANSFER_COMPLETE_TIMEOUT macro definition, customer can set the timeout value in Milliseconds.
Source code located at <fsl_sdmmc_host.c> file.
Wish it helps.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks Mike.
Joe
Thanks Mike.
I had implemented code that would reset and re-initialize the SDHC upon "timeout" detection. I was hoping a simpler method was available since the time to initialize is long.
Joe
Hi Joe,
I also checked the MCUXpresso SDK for K64 about SDCard application, which also using timeout to check error recovery condition. With the SDMMCHOST_TRANSFER_COMPLETE_TIMEOUT macro definition, customer can set the timeout value in Milliseconds.
Source code located at <fsl_sdmmc_host.c> file.
Wish it helps.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
First of all, sorry for the later reply.
I checked the MQX file system for SD card demo, which also using timeout to jump out of error issue.
Please check attached code for the detailed info of <_io_sdcard_esdhc_read_block> function.
Wish it helps.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------