2020-08-26 07:02 AM
Dear all,
I am having a problem with SDIO (SDMMC2) interface on STM32F769i Discovery. I use the DMA-based SDIO, CubeMX (v5.6.1) to generate the codes. Also freeRTOS enabled.
After I called "BSP_SD_WriteBlocks_DMA(aTxBuffer, BLOCK_START_ADDR, NUM_OF_BLOCKS);", at some point, the HAL_SD_IRQHandler is triggered. and inside this handler, I got an error: HAL_SD_ERROR_DATA_CRC_FAIL. Then HAL_SD_ErrorCallback is triggered, instead of the HAL_SD_TxCpltCallback.
Any clue what is the cause of this CRC error? My settings are following:
I added SD_initialize(0) in the FATFS_Init function.
void MX_FATFS_Init(void)
{
/*## FatFS: Link the SD driver ###########################*/
retSD = FATFS_LinkDriver(&SD_Driver, SDPath);
/* USER CODE BEGIN Init */
/* additional user code for init */
SD_initialize(0);
/* USER CODE END Init */
}
/**
* @brief Initializes a Drive
* @param lun : not used
* @retval DSTATUS: Operation status
*/
DSTATUS SD_initialize(BYTE lun)
{
Stat = STA_NOINIT;
/*
* check that the kernel has been started before continuing
* as the osMessage API will fail otherwise
*/
#if (osCMSIS <= 0x20000U)
if(osKernelRunning())
#else
if(osKernelGetState() == osKernelRunning)
#endif
{
#if !defined(DISABLE_SD_INIT)
if(BSP_SD_Init() == MSD_OK)
{
Stat = SD_CheckStatus(lun);
}
#else
Stat = SD_CheckStatus(lun);
#endif
/*
* if the SD is correctly initialized, create the operation queue
* if not already created
*/
if (Stat != STA_NOINIT)
{
if (SDQueueID == NULL)
{
#if (osCMSIS <= 0x20000U)
osMessageQDef(SD_Queue, QUEUE_SIZE, uint16_t);
SDQueueID = osMessageCreate (osMessageQ(SD_Queue), NULL);
#else
SDQueueID = osMessageQueueNew(QUEUE_SIZE, 2, NULL);
#endif
}
if (SDQueueID == NULL)
{
Stat |= STA_NOINIT;
}
}
}
return Stat;
}
Solved! Go to Solution.
2020-08-31 11:28 PM
I found the reason. The CubeMX assigned a PIN for sdmmc2-D3, which is not the PIN connected to D3 in the discovery board. After fixing this, everything works.
2020-08-31 12:24 AM
Does anyone have an idea what could cause the CRC error?
2020-08-31 11:28 PM
I found the reason. The CubeMX assigned a PIN for sdmmc2-D3, which is not the PIN connected to D3 in the discovery board. After fixing this, everything works.