STM32L451 UART circular DMA receptions not generating a full buffer (TC) interrrupt
Hi.
I’m using CubeIDE, CubeMX and HAL to create an application for an STM32L451.
I’ve setup USART1 to receive via DMA in circular mode and detect line idle, starting receptions with HAL_UARTEx_ReceiveToIdle_DMA(), and processing receptions in callback HAL_UARTEx_RxEventCallback().
All seems to work fine except that the TC (transfer complete, or full buffer) interrupt never happens.HT (half transfer, or half of the buffer reached) and line idle do interrupt.
I’m providing HAL_UARTEx_ReceiveToIdle_DMA() a buffer of size 128 bytes. I’m logging the value of the size argument to HAL_UARTEx_RxEventCallback(). When I manually send a message of 20 bytes repeatedly, but slowly enough to ensure line idle triggers, the callback is called with the following size values: 20, 40, 60, 64, 80, 100, 120, 120, 12, 32, 52, 64, 72, 92, 112, 112, 4, 24, (etc).
You can see that line idle works, and also that HT is issued in the middle of a reception (size == 64), but TC isn’t, there’s no size equal to 128.
What’s also odd is that the callback is always called twice with the same last size value before the buffer wraps back to 0: in the above example at size==120, and in the next loop at size==112. If I use different buffer or message sizes, or keep on iterating, etc, I always get a double call at some point before the buffer is full, but never at exactly the buffer’s size.
Is my expectation of getting an interrupt at full buffer wrong? Why is always a second interruption with no further data just before a new message makes the buffer wrap around to 0, but not at the buffer’s full size?
Thanks for any insight.
