cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UART_Transmit_DMA does not trigger HAL_UART_TxCpltCallback interrupt

JBond.1
Senior

Hi, I want to use UART with DMA on my STM32F407 MCU. I would expect that it would trigger `HAL_UART_TxCpltCallback` interrupt on transfer complete, but it does not do that. I tried many different configurations in STM32CubeMX:

  • enabling "USART2 global interrupt"
  • enabling DMA "Circular mode"
  • enabling "Use FIFO" "Threshold Full"

JBond1_0-1698569473393.png

But still interrupt is not triggering. Why? And how to I make it to trigger?
(also I would prefer using DMA in "normal mode" as I need to send messages one by one)

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @JBond.1 

Here is the explanation: MX_DMA_Init guarantees clocks enabled for the DMA, while HAL_UART_MspInit already uses the DMA units and sets them up. Without clock enabled, the DMA setup fails, and the peripheral doesn't have valid configuration.

Updating the latest version of CubeMX is recommended.

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3

Is the UART or DMA peripheral flagging some sort of error status? Read the registers. 

What is the memory address for the buffer?

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

There seems to be no errors. I think buffer is also good. I have STM32CubeMX 6.6.1 and it seems I have found the problem. The issue is that `MX_USART2_UART_Init()` is called before `MX_DMA_Init()`. Code generated by STM32CubeMX 6.6.1:

 

  MX_GPIO_Init();
  MX_CAN1_Init();
  MX_SDIO_SD_Init();
  MX_TIM2_Init();
  MX_TIM3_Init();
  MX_FATFS_Init();
  MX_USART2_UART_Init();
  MX_DMA_Init();
  MX_SPI3_Init();
  MX_TIM4_Init();
  MX_TIM1_Init();

 

Not sure why that cause interrupts not to fire?

https://community.st.com/t5/stm32cubemx-mcus/the-calls-to-mx-dma-init-and-mx-usart2-uart-init-are-generated/td-p/198369

Hello @JBond.1 

Here is the explanation: MX_DMA_Init guarantees clocks enabled for the DMA, while HAL_UART_MspInit already uses the DMA units and sets them up. Without clock enabled, the DMA setup fails, and the peripheral doesn't have valid configuration.

Updating the latest version of CubeMX is recommended.

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.