cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_MMC_RxCpltCallback never called from HAL_MMC_ReadBlocks_DMA

LDAP7907
Associate

I'm following the example the USB MSC Standalone example provided here:
https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM32446E_EVAL/Applications/USB_Device/MSC_Standalone/Src/usbd_storage.c

I am attempting to get the eMMC that is connected to my STM32F466RE to be detected as a Mass Storage device on the PC.

 

int8_t STORAGE_Read_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
  /* USER CODE BEGIN 6 */

  uint32_t timeout = 100000;
  HAL_StatusTypeDef status = HAL_MMC_ReadBlocks_DMA(&hmmc, buf, blk_addr, blk_len);
  /* Wait for Rx Transfer completion */
while (readstatus == 0){} // <- STUCK HERE
  readstatus = 0;

    while(HAL_MMC_GetCardState(&hmmc) != HAL_MMC_CARD_TRANSFER)
  {
    if (timeout-- == 0)
    {
      return (USBD_FAIL);
    }
  }

  return (USBD_OK);
  /* USER CODE END 6 */
}

 

 

 

/**
  * @brief BSP Rx Transfer completed callbacks
  * @PAram None
  * @retval None
  */
void HAL_MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc)
{
  readstatus = 1;
}

 

 

In the STM32F4 example, the HAL_MMC_RxCpltCallback  function is called to clear the readstatus flag. However, in my code the HAL_MMC_RxCpltCallback is never called and thus gets stuck in the while loop shown in the first code block.

If I remove the while loop altogether, then the code actually does enter in the HAL_MMC_RxCpltCallback as expected and clears the flag. So is the while loop blocking it somehow?

Here's my interrupt, DMA, and clock settings:
Screenshot 2023-09-23 at 1.40.44 PM.pngScreenshot 2023-09-23 at 1.40.59 PM.pngScreenshot 2023-09-23 at 1.41.16 PM.pngScreenshot 2023-09-23 at 1.41.25 PM.png
1 REPLY 1
Issamos
Lead II

Hello @LDAP7907 

I advice you to debug your code step by step your code to localise the issue.

Best regards.

II