Hi,
I am currently trying to add SD card and FatFS functionality to an existing project however I am having some difficulty getting the SD card to initialize correctly. My code is based off the SDK example for using FreeRTOS, FatFS, and SDMMC.
When trying to initialize the SD card using SD_CardInit the project will get stuck waiting when trying to read the SCR from the SD card. Specifically it gets stuck while executing the SDMMCHOST_TransferFunction during the data transfer event, see screenshot attached. Upon executing the SDMMC_OSA_EventWait (as shown in screenshot) FreeRTOS will proceed to return to an idle task and remain there until the program is stopped.
Any ideas on how to resolve this issue?
Thanks,
Jon McLean
Code Screenshot:
Debug Thread Screenshot:
FreeRTOS Task Screenshot:
Card Detect Task Code:
static void CardDetectTask(void *pvParameters) {
cardDetectSemaphore = xSemaphoreCreateBinary();
BOARD_SD_Config(&g_sd, SDCARD_DetectCallback, BOARD_SDMMC_SD_HOST_IRQ_PRIORITY, NULL);
if(SD_HostInit(&g_sd) == kStatus_Success) {
while(true) {
if(xSemaphoreTake(cardDetectSemaphore, portMAX_DELAY) == pdTRUE) {
if(cardInserted != cardInsertedStatus) {
cardInserted = cardInsertedStatus;
if(cardInserted) {
PRINTF("Card Inserted\r\n");
SD_SetCardPower(&g_sd, false);
SD_SetCardPower(&g_sd, true);
PRINTF("\r\n\Initialising SD Card \r\n");
SD_CardInit(&g_sd);
PRINTF("\r\nFinished Card Init\r\n");
if(DEMO_MakeFileSystem() != kStatus_Success) {
continue;
}
// Notify Tasks
}
}
if(!cardInserted) {
PRINTF("\r\n No SD card, please insert \r\n");
}
}
}
}else {
PRINTF("\r\nSD Host Init Failed\r\n");
}
vTaskSuspend(NULL);
}
Same issue
Using SDcard hangs waiting for OSAevent
Any soultion?
@JonMcLeanSMC
@Omar_Anguiano
Thanks
AKHIL
Hello
Hope you are well.
Are you using the EVK? Which SDK version are you using?
Is this issue persistent on all the available SD cards?
Please let me know so we can find the root cause of this issue.
Best regards,
Omar
Hi @Omar_Anguiano ,
Thanks for the response. This issue occurs across all SD cards I have available (all SDHC). I am not using an EVK board and am instead using a custom development board. I am using SDK version 2.12.1.
Also I have done some further investigation since my last post and have managed to use a logic analyzer to get the following output which shows the SCR is sent and a response is given by the card (which as far as I can tell is then ignored by the host, hence causing the program to hang).
Additionally I have contacted the manufacturer of the board I am using to confirm the pin configurations are correct. I've attached the full output from the logic analyzer below (produced using pulseview). Let me know if you have any ideas as to what could be causing this.
Thanks,
Jon McLean
EDIT: I've also attached a better screenshot of the logic analyzer that contains the channel names for each of the traces
Thank you for your additional information. Is it possible to receive some additional information from the board you´re using since this issue is not present on the EVK?
Additionally, it will be helpful if you add some information about the SD card used.
Does the SDK unmodified example work correctly? It can be helpful to restart the host before initializing the Sdcard.