AnsweredAssumed Answered

DMA Write Issues with STM32L4R9-DISCO SDMMC

Question asked by Clive Two.Zero on Jan 5, 2018
Latest reply on May 17, 2018 by Imen D

The HAL_SD_ErrorCallback() is called EVERY time a one sector DMA Write is used

 

ie

SD_state = BSP_SD_WriteBlocks_DMA((uint32_t *)buff, sector, count); // With count == 1

 

void SDMMC1_IRQHandler(void)
{
HAL_SD_IRQHandler(&hsd_discovery); // Calls the handler
}

 

Here is the offending code in STM32L4xx_hal_sd.c, errorstate is 4 CMD_RSP_TIMEOUT

 

void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd)
{

...
else if((hsd->Context & SD_CONTEXT_DMA) != RESET)
{
#if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
hsd->Instance->DLEN = 0;
hsd->Instance->DCTRL = 0;
hsd->Instance->IDMACTRL = SDMMC_DISABLE_IDMA;

/* Stop Transfer for Write Single/Multi blocks or Read Multi blocks */
if((hsd->Context & SD_CONTEXT_READ_SINGLE_BLOCK) == RESET)
{
errorstate = SDMMC_CmdStopTransfer(hsd->Instance);
if(errorstate != HAL_SD_ERROR_NONE)
{
hsd->ErrorCode |= errorstate;
HAL_SD_ErrorCallback(hsd);
}
}

...

 

 

It ends up here, and if I call Error_Handler(), basically GAME OVER

 

/**
* @brief SDMMC error callback
* @param None
* @retval None
*/
void HAL_SD_ErrorCallback(SD_HandleTypeDef *hsd)
{
puts("HAL_SD_ErrorCallback");
}

 

 

Getting 10.1 MBps Write Speeds, and 12.2 Read Speeds in current testing

Outcomes