Skip to main content
Explorer
June 19, 2025
Solved

STM32G4xx HAL Driver V1.2.5 Issue with DMAMUX

  • June 19, 2025
  • 1 reply
  • 370 views

Hello ST,

I would like to report a bug in the <stm32g4xx_hal_dma.c> file (V1.2.5). In the function DMA_CalcDMAMUXChannelBaseAndMask(DMA_HandleTypeDef *hdma), there's an error in calculating hdma->DMAmuxChannelStatusMask. For DMA2 channels, the channel_number should be adjusted by adding 8, 6, or 7 according to the MCU category. Otherwise, it will NOT be able to correctly determine and clear the synchronization overrun interrupt of the corresponding channel.

To give you a better understanding of the issue, I've included some relevant code snippets with comments at Line 32 below:

/**
 * @brief Updates the DMA handle with the DMAMUX channel and status mask depending on stream number
 * @PAram hdma pointer to a DMA_HandleTypeDef structure that contains
 * the configuration information for the specified DMA Stream.
 * @retval None
 */
static void DMA_CalcDMAMUXChannelBaseAndMask(DMA_HandleTypeDef *hdma)
{
 uint32_t dmamux_base_addr;
 uint32_t channel_number;
 DMAMUX_Channel_TypeDef *DMAMUX1_ChannelBase;

 /* check if instance is not outside the DMA channel range */
 if ((uint32_t)hdma->Instance < (uint32_t)DMA2_Channel1)
 {
 /* DMA1 */
 DMAMUX1_ChannelBase = DMAMUX1_Channel0;
 }
 else
 {
 /* DMA2 */
#if defined (STM32G471xx) || defined (STM32G473xx) || defined (STM32G474xx) || defined (STM32G414xx) || defined (STM32G483xx) || defined (STM32G484xx) || defined (STM32G491xx) || defined (STM32G4A1xx) || defined (STM32G411xC)
 DMAMUX1_ChannelBase = DMAMUX1_Channel8;
#elif defined (STM32G411xB) || defined (STM32G431xx) || defined (STM32G441xx) || defined (STM32GBK1CB)
 DMAMUX1_ChannelBase = DMAMUX1_Channel6;
#else
 DMAMUX1_ChannelBase = DMAMUX1_Channel7;
#endif /* STM32G4x1xx) */
 }
 dmamux_base_addr = (uint32_t)DMAMUX1_ChannelBase;
 channel_number = (((uint32_t)hdma->Instance & 0xFFU) - 8U) / 20U;
 /** Code should be added here to distinguish DMA2 channels from DMA1 ones. **/
 hdma->DMAmuxChannel = (DMAMUX_Channel_TypeDef *)(uint32_t)(dmamux_base_addr + ((hdma->ChannelIndex >> 2U) * ((uint32_t)DMAMUX1_Channel1 - (uint32_t)DMAMUX1_Channel0)));
 hdma->DMAmuxChannelStatus = DMAMUX1_ChannelStatus;
 hdma->DMAmuxChannelStatusMask = 1UL << (channel_number & 0x1FU);
}

Best regards,
Penguins

    This topic has been closed for replies.
    Best answer by Saket_Om

    Hello @Penguins 

    Thank you for bringing this to our attention 

    I reported this internally 

    Internal ticket number: 212655 (This is an internal tracking number and is not accessible or usable by customers).

    1 reply

    Saket_OmAnswer
    Technical Moderator
    June 20, 2025

    Hello @Penguins 

    Thank you for bringing this to our attention 

    I reported this internally 

    Internal ticket number: 212655 (This is an internal tracking number and is not accessible or usable by customers).

    PenguinsAuthor
    Explorer
    November 22, 2025

    I noticed that this issue has not been fixed yet.

    Technical Moderator
    November 24, 2025

    Hello @Penguins 

    The fix is scheduled to be released on GitHub soon.