STM32WB5MM:HAL_UARTEx_ReceiveToIdle_DMA reports IDLE event with Size=256 although the logic analyzer shows continuous data (USART1, DMA Normal)
The STM32 sends an HTTP GET with the AT command AT#XHTTPCREQ. The modem answers with the HTTP header, a #XHTTPCRSP:<len>,<state> line and the body. The complete response is about 4432 bytes. I start reception with:
HAL_UART_AbortReceive(&huart1);
while (HAL_UART_GetState(&huart1) != HAL_UART_STATE_READY);
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, (uint8_t*)rx_buffer, 4500); // buffer is 4500 bytesProblemHAL_UARTEx_RxEventCallback is called with huart->RxEventType == HAL_UART_RXEVENT_IDLE and Size = 256, and the reception ends. The value is always exactly 256, and the rest of the response is not received!!
Setup:
- MCU: STM32WB5MMGH
- IDE / CubeMX / HAL package version 6.15.0
- Peer device: nRF9160 running Serial LTE Modem (AT commands over UART)
Cube configuration:
- USART1: asynchronous, 115200 baud, 8N1, oversampling 16, FIFO mode disabled, hardware flow control disabled, overrun enabled, DMA on RX error enabled
- USART1_RX: DMA1 Channel 3, peripheral to memory, Normal mode, byte/byte, memory increment on, priority High
- USART global interrupt and DMA1 channel 3 interrupt enabled
Observation:
- Without breakpoints:
RxEvent type=2 (IDLE) Size=256. - With a breakpoint placed right after the
HAL_UARTEx_ReceiveToIdle_DMAcall, the callback reportstype=1 (HT) Size=4432, thentype=2 (IDLE) Size=4432. I assume this is because the CPU was halted while the DMA kept filling the buffer. - A logic analyzer on the modem TX line shows no idle gap at the 256-byte position!!
Questions
- Under what conditions can the USART IDLE flag be set while the line is carrying continuous data? For example: a clock, baud or sampling issue, noise on RX, or a very short gap (about one frame time, 87 µs) that a logic analyzer misses.
- Is there any configuration I missed, or any USART/DMA interaction on the STM32WB, that could produce an IDLE event at a fixed position such as 256 bytes?

