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);
}