AnsweredAssumed Answered

sdhc_drv_init() fail?

Question asked by Audi McAvoy on Apr 16, 2015
Latest reply on Aug 4, 2015 by Erich Styger

My 2GB Transcan microSD card does not initialize correctly when my FRD-K64F is powered up.  Only after pressing the reset button is the card accessible.  Well, almost "only."


Using KDS, I have created a simple app based on the FRDM-K64F with PE and KSDK support.


Using PE, I added a debug console (debug_console), a memory card (fsl_sdcard) and a GPIO pin (fsl_gpio) to my project.  The memory card is setup for 4-bit access, and the GPIO pin is setup as a card detect input.  Everything is configured from the FRDM-K64F schematic.


On power up, the blocksize member in my sdhc_card_t structure is "0" (in fact, all members appear to be zeroed), and the card is not accessible.  Pressing the reset button then initializes the card structure, and everything works as expected.


I have also found that shutting down the SDHC driver, then reinitializing the SDHC and the SDCARD drivers "fixes" the problem.  Like this. . .


if (0 == memoryCard1_state.blockSize) { #if 0   SDCARD_DRV_Shutdown(&memoryCard1_state); #endif    SDHC_DRV_Shutdown(FSL_FSL_SDHC1);    if (kStatus_SDHC_NoError != SDHC_DRV_Init(FSL_FSL_SDHC1, &fsl_sdhc1_host, &fsl_sdhc1_InitConfig0)) {     printf("SDHC_DRV_Init() error\r\n");     return false;   }    if (kStatus_SDHC_NoError != SDCARD_DRV_Init(&fsl_sdhc1_host, &memoryCard1_state)) {     printf("SDCARD_DRV_Init() error\r\n");     return false;   }    if (0 == memoryCard1_state.blockSize) return false; } return true;


Notice that calling SDCARD_DRV_Shutdown() hung the processor.  On the other hand, not calling SDHC_DRV_Shutdown() followed by SDHC_DRV_Init() was not sufficient to restore SD card access.  Also, calling SDHC_DRV_Init() without first calling SDHC_DRV_Shutdown() was problematic.


I've attached my project.


Does anyone have any suggestions?

Original Attachment has been moved to: