STM32L496RGT SDMMC DMA FATFS
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-10 4:45 AM
Hi,
in CubeMX 6.1.1 with FW package 1.16.0. If I choice in SDMMC with DMA template enable and shared DMA channel CubeMX doesn't generate proper code. In BSP_SD_ReadBlocks_DMA and in BSP_SD_WriteBlocks_DMA miss setting for change DMA direction. Solution:
__weak uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
{
uint8_t sd_state = MSD_OK;
__HAL_DMA_DISABLE(hsd1.hdmatx);
hsd1.hdmatx->Init.Direction = DMA_MEMORY_TO_PERIPH;
hsd1.hdmatx->Instance->CCR |= (uint32_t)DMA_CCR_DIR;
/* Write block(s) in DMA transfer mode */
if (HAL_SD_WriteBlocks_DMA(&hsd1, (uint8_t *)pData, WriteAddr, NumOfBlocks) != HAL_OK)
{
sd_state = MSD_ERROR;
}
return sd_state;
}
__weak uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
{
uint8_t sd_state = MSD_OK;
__HAL_DMA_DISABLE(hsd1.hdmatx);
hsd1.hdmatx->Init.Direction = DMA_MEMORY_TO_PERIPH;
hsd1.hdmatx->Instance->CCR |= (uint32_t)DMA_CCR_DIR;
/* Write block(s) in DMA transfer mode */
if (HAL_SD_WriteBlocks_DMA(&hsd1, (uint8_t *)pData, WriteAddr, NumOfBlocks) != HAL_OK)
{
sd_state = MSD_ERROR;
}
return sd_state;
}
please repair it.
Solution first posted superspud9 on reddit.
Thanks
Labels:
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-14 8:41 AM
This was (almost) the solution to my problem.Looks like the write code was pasted twice, when you do need a version of the read code to set the direction bit back.
But it's not hard at all to convert one to the other.
