2025-03-13 4:45 AM
Hello, ST experts
HAL_UARTEx_ReceiveToIdle_DMA works well in our project, it can get idle interrupt or uart data stream interrupt. But when STM32's partner power down and up again, I think that means UART_RX line to STM32 goes low during this period, the call of HAL_UARTEx_ReceiveToIdle_DMA always returns an error code. How can I restore in such situation?
BR
Yang
2025-03-13 5:54 AM
Probably the UART has an error flag set. Look at the handle to see what state the peripheral is in. Implement HAL_UART_ErrorCallback. Deinitialize/reinitialize UART if needed.
2025-03-13 6:59 AM
@Yang Yang wrote:But when STM32's partner power down and up again,
you will almost certainly get a glitch in such an event - you will often see this on a terminal as a "junk" character when something is plugged-in, unplugged, and/or power-cycled.
@Yang Yang wrote:the call of HAL_UARTEx_ReceiveToIdle_DMA always returns an error code.
So what error code, exactly, does it return?
Quite likely, there will be a framing error and/or other UART errors - as @TDK suggested.
@Yang Yang wrote:How can I restore in such situation?
Make sure you properly handle glitches on the line - including UART errors, etc ...