2023-12-03 12:21 PM
Hi everyone, I've done these steps before on STM32F0, STM32F1 and STM32F4 microcontrollers to detect when a circular DMA buffer for UART "wraps" (The counter finishes with the array and starts from the beginning again) with complete success
However when I implemented the steps above on a STM32L431RCT microcontroller, I've noticed that the interrupt only works 9 out of 10 times. This means that there are times that the buffer will wrap, but my variable wouldn't increment by one. This is very strange as the exact same code worked flawlessly on other families of STM32 microcontrollers that I had used such as STM32F0. I was not able to find the issue by looking at the reference manual and the HAL code, can anyone help me with this?
Thanks a lot
Solved! Go to Solution.
2023-12-03 12:30 PM
If DMA1_Channel5_IRQHandler is called for some other reason, say due to the HT flag or a flag other than TC, you have a race condition. If TC gets set after you check it, but before it's processed within HAL_DMA_IRQHandler, it will be cleared without your code being called. If you're going to use HAL, put the check in the RX complete callback instead.
The RXNE interrupt shouldn't be enabled if you're handling it with DMA.
2023-12-03 12:30 PM
If DMA1_Channel5_IRQHandler is called for some other reason, say due to the HT flag or a flag other than TC, you have a race condition. If TC gets set after you check it, but before it's processed within HAL_DMA_IRQHandler, it will be cleared without your code being called. If you're going to use HAL, put the check in the RX complete callback instead.
The RXNE interrupt shouldn't be enabled if you're handling it with DMA.