Skip to main content
Yang Yang
Associate III
Mar 13, 2025 11:45 AM UTC
Solved

HAL_UARTEx_ReceiveToIdle_DMA return HAL_ERROR when stm32's partner restart

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

This topic has been closed for replies.
TDK
TDKBest answer
Mar 13, 2025 12:54 PM UTC

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."

3 replies

TDK
TDKBest answer
Mar 13, 2025 12:54 PM UTC

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.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Andrew Neil
Super User
Mar 13, 2025 1:59 PM UTC

@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 ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Yang Yang
Yang YangAuthor
Associate III
Mar 14, 2025 12:57 AM UTC

Hello, Andrew

 

Does that mean if a frame error occured, Deinitialize/reinitialize UART might be needed in HAL_UART_ErrorCallback ?

 

BR

Yang