cancel
Showing results for 
Search instead for 
Did you mean: 

DMA Write Issues with STM32L4R9-DISCO SDMMC

Posted on January 05, 2018 at 23:33

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

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
5 REPLIES 5
John Craven
Senior
Posted on January 06, 2018 at 19:21

Clive isn't this where you or one of there other gurus would normally post something like 'I don't use HAL'. Lol

Posted on January 07, 2018 at 14:06

HAL is now a requirement...

🙂

 

Soon it will be so HAL-centric around here that you won't be able to sustain your guru status anymore without using HAL effectively.

Posted on January 07, 2018 at 15:03

In a world full of Cargo Cult Programmers the guy that can find his own pants and put them on will always appear to be a genius.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Imen.D
ST Employee
Posted on May 17, 2018 at 17:15

Hello

Turvey.Clive.002

,

Thanks a lot foryour contribution andhighlighting this issue.

We confirm thatthe 'Stop Transfer' command should be sent only in case of multiple read or write, not single write.

This will be fixed in the coming version.

With Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

Hello @Community member​ ,

The HAL SD driver within the new CubeL4 version 1.12.0, fixed the DMA write issue and send the "Stop transfer" command only in case of multiple read or write operations.

With Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen