Skip to main content
Yang Yang
Associate III
March 13, 2025
Solved

HAL_UARTEx_ReceiveToIdle_DMA return HAL_ERROR when stm32's partner restart

  • March 13, 2025
  • 3 replies
  • 1182 views

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.
Best answer by TDK

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.

3 replies

TDK
TDKBest answer
March 13, 2025

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
March 13, 2025

@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
March 14, 2025

Hello, Andrew

 

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

 

BR

Yang