STM32CubeF1 icon indicating copy to clipboard operation
STM32CubeF1 copied to clipboard

MMC DMA Reads/Writes Fail to Update DMA Direction

Open jhansen3141 opened this issue 4 years ago • 4 comments

In stm32f1xx_hal_mmc.c, HAL_MMC_ReadBlocks_DMA and HAL_MMC_WriteBlocks_DMA, the DMA direction is set in the DMA CCR register before starting the DMA transfer. However, this register cannot be updated without first disabling DMA (clearing the EN bit in the CCR register). This is not currently done in the driver and therefore the DMA direction is never updated between MMC reads and writes.

hmmc->hdmatx->Init.Direction = DMA_MEMORY_TO_PERIPH;
MODIFY_REG(hmmc->hdmatx->Instance->CCR, DMA_CCR_DIR, hmmc->hdmatx->Init.Direction); // Fails to set because EN bit is set
__HAL_DMA_DISABLE(hmmc->hdmatx);
hmmc->hdmatx->Init.Direction = DMA_MEMORY_TO_PERIPH;
MODIFY_REG(hmmc->hdmatx->Instance->CCR, DMA_CCR_DIR, hmmc->hdmatx->Init.Direction); // Works because EN bit was cleared above

This issue can be overcome by having the application code disable DMA (call __HAL_DMA_DISABLE(hdma) before calling either HAL_MMC_WriteBlocks_DMA or HAL_MMC_ReadBlocks_DMA. However, the driver should be fixed so this is not required.

jhansen3141 avatar Oct 13 '21 21:10 jhansen3141

Hi @jhansen3141,

Thank you for your contribution. The reported point will be forwarded to our development teams. I will get to you as soon as they provide their feedback.

Thank you again for your contribution and for your patience.

With regards,

RKOUSTM avatar Dec 20 '21 09:12 RKOUSTM

Hi @jhansen3141,

Thank you for this report. We will get back to you with a feedback as soon as possible. Please excuse the delay it may take us sometimes to reply. Thank you for your comprehension.

With regards,

ALABSTM avatar Jan 30 '22 08:01 ALABSTM

Hi @jhansen3141,

Thank you for your contribution. An update of the MMC HAL driver will take this problem into into account and it will be made available in the frame of a future release v1.8.5.

Thank you again for this contribution and thank you in advance for your patience.

With regards,

RKOUSTM avatar Feb 28 '22 15:02 RKOUSTM

ST Internal Reference: 110782

RKOUSTM avatar Apr 15 '22 11:04 RKOUSTM

Hello @jhansen3141

Thank you again for having reported this point. It has been fixed in the frame of version 1.8.5 of this firmware.

With regards,

RJMSTM avatar Apr 14 '23 11:04 RJMSTM