Skip to main content
Iswarya
Associate III
November 6, 2019
Question

SDMMC 4 bit mode with DMA (STM32L4R7)

  • November 6, 2019
  • 1 reply
  • 983 views

Hi,

I'm trying to configure SDMMC module using DMA since I'm using FREERTOS. But in STM32CUBEMX, there is no option to configure DMA settings under FATfs.

So, I'm trying to setup the DMA configuration through code.

I can see that there is no definition for DMA SDMCC request in stm32l4xx_hal_dma.h .

When I trying to use the following line, I get the error message says that "no member named hdmarx in __SD_Handle_Typedef"

__HAL_LINKDMA(&hsd1,hdmarx,hdma_sdmmc1_rx);

 DMA_HandleTypeDef hdma_sdmmc1_rx;
 
 DMA_HandleTypeDef hdma_sdmmc1_tx;
 
 
 static DMA_HandleTypeDef hdmatx;
 
 static DMA_HandleTypeDef hdmarx;
 
 
 /* DMA controller clock enable */
 
 __HAL_RCC_DMAMUX1_CLK_ENABLE();
 
 __HAL_RCC_DMA2_CLK_ENABLE(); 
 
 
 /* SDMMC1 DMA Init */
 
 /* SDMMC1_RX Init */
 
 hdma_sdmmc1_rx.Instance = DMA2_Channel4;
 
 hdma_sdmmc1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
 
 hdma_sdmmc1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
 
 hdma_sdmmc1_rx.Init.MemInc = DMA_MINC_ENABLE;
 
 hdma_sdmmc1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
 
 hdma_sdmmc1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
 
 hdma_sdmmc1_rx.Init.Mode = DMA_NORMAL;
 
 hdma_sdmmc1_rx.Init.Priority = DMA_PRIORITY_LOW;
 
 hdma_sdmmc1_rx.Init.Request = DMA_REQUEST_UART4_RX;
 
 if (HAL_DMA_Init(&hdma_sdmmc1_rx) != HAL_OK)
 
 {
 
 Error_Handler();
 
 }
 
 
 __HAL_LINKDMA(&hsd1,hdmarx,hdma_sdmmc1_rx);
 
 
 /* SDMMC1_TX Init */
 
 hdma_sdmmc1_tx.Instance = DMA2_Channel5;
 
 hdma_sdmmc1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
 
 hdma_sdmmc1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
 
 hdma_sdmmc1_tx.Init.MemInc = DMA_MINC_ENABLE;
 
 hdma_sdmmc1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
 
 hdma_sdmmc1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
 
 hdma_sdmmc1_tx.Init.Mode = DMA_NORMAL;
 
 hdma_sdmmc1_tx.Init.Priority = DMA_PRIORITY_LOW;
 
 
 if (HAL_DMA_Init(&hdma_sdmmc1_tx) != HAL_OK)
 
 {
 
 Error_Handler();
 
 }
 
 
 __HAL_LINKDMA(&hsd1,hdmatx,hdma_sdmmc1_tx);

Please help me to configure SDMMC using DMA

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
November 6, 2019

>>When I trying to use the following line, I get the error message says that "no member named hdmarx in __SD_Handle_Typedef"

Ok, so why wouldn't you look inside the structure definition to see what is and is not defined there?

Might also help significantly to pull the right Reference Manual for the part you're using, RM0432

https://www.st.com/resource/en/reference_manual/dm00310109.pdf

https://www.st.com/en/microcontrollers-microprocessors/stm32l4r7vi.html#resource

Doesn't the L4+ have a committed DMA unit?

For workable reference code see:

STM32Cube_FW_L4_V1.14.0\Drivers\BSP\STM32L4R9I-Discovery\stm32l4r9i_discovery_sd.c

STM32Cube_FW_L4_V1.14.0\Projects\32L4R9IDISCOVERY\Demonstrations\MenuLauncher\Core\Src\sd_diskio_dma.c

STM32Cube_FW_L4_V1.14.0\Projects\32L4R9IDISCOVERY\Examples\BSP\Src\sd.c

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..