cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UARTEx_ReceiveToIdle_DMA return HAL_ERROR when stm32's partner restart

Yang Yang
Associate II

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

2 REPLIES 2
TDK
Guru

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

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