2023-10-29 01: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:
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.
2023-10-30 02: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.
2023-10-29 05: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?
2023-10-29 06:35 AM - edited 2023-10-29 06: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?
2023-10-30 02: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.