SDHC Error Recovery

cancel
Showing results for 
Search instead for 
Did you mean: 

SDHC Error Recovery

Jump to solution
637 Views
JHinkle
Senior Contributor I

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

0 Kudos
1 Solution
448 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

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.

pastedImage_1.png

Wish it helps.


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
4 Replies
448 Views
JHinkle
Senior Contributor I

Thanks Mike.

Joe

0 Kudos
448 Views
JHinkle
Senior Contributor I

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

0 Kudos
449 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

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.

pastedImage_1.png

Wish it helps.


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
448 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

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.

pastedImage_1.png

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos