cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO on STM32F769i Discovery

Sfu.1
Associate II

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:

 0693W000002lEQFQA2.png

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

1 ACCEPTED SOLUTION

Accepted Solutions
Sfu.1
Associate II

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.

View solution in original post

2 REPLIES 2
Sfu.1
Associate II

Does anyone have an idea what could cause the CRC error?

Sfu.1
Associate II

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.