Skip to main content
Visitor II
March 13, 2025
Solved

HAL_UARTEx_ReceiveToIdle_DMA return HAL_ERROR when stm32's partner restart

  • March 13, 2025
  • 2 replies
  • 1133 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.

    2 replies

    TDKAnswer
    Super User
    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.

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

    Yang YangAuthor
    Visitor II
    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