HAL_UART_Transmit_DMA does not trigger HAL_UART_TxCpltCallback interrupt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-29 1:52 AM
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"
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)
Solved! Go to Solution.
- Labels:
-
DMA
-
Interrupt
-
UART-USART
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-30 2:33 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-29 5:01 AM
Is the UART or DMA peripheral flagging some sort of error status? Read the registers.
What is the memory address for the buffer?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-29 6:35 AM - edited ‎2023-10-29 6:38 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-30 2:33 AM
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.
