cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32h753zi uart error handler

A3
Associate III

Hi,

When HAL_Uart_errorhandler is triggered, how can we check if the trigger is for reception or transmission?

4 REPLIES 4

Check the UART error & status flags - each one will be applicable to only receive or transmit.

eg, you can't get framing or parity errors on transmit - only receive!

Possible UART errors listed below, and which one is for TX, and which one is for RX mentioned below. Please let me know if my understandings are correct.

#define HAL_UART_ERROR_NONE (0x00000000U) /*!< No error */
#define HAL_UART_ERROR_PE (0x00000001U) /*!< Parity error */
#define HAL_UART_ERROR_NE (0x00000002U) /*!< Noise error */
#define HAL_UART_ERROR_FE (0x00000004U) /*!< Frame error */
#define HAL_UART_ERROR_ORE (0x00000008U) /*!< Overrun error */
#define HAL_UART_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
#define HAL_UART_ERROR_RTO (0x00000020U) /*!< Receiver Timeout error */


Receive Error: HAL_UART_ERROR_PE, HAL_UART_ERROR_FE, HAL_UART_ERROR_NE, HAL_UART_ERROR_ORE, HAL_UART_ERROR_RTO, HAL_UART_ERROR_DMA
Transmit Error: HAL_UART_ERROR_DMA

Look-up the definitions of those bits in the Reference Manual.

These, by definition,  can only happen on receive:

#define HAL_UART_ERROR_PE (0x00000001U) /*!< Parity error */
#define HAL_UART_ERROR_NE (0x00000002U) /*!< Noise error */
#define HAL_UART_ERROR_FE (0x00000004U) /*!< Frame error */
#define HAL_UART_ERROR_RTO (0x00000020U) /*!< Receiver Timeout error */

 

 These you'd have to check in the Refence Manual:

#define HAL_UART_ERROR_ORE (0x00000008U) /*!< Overrun error */
#define HAL_UART_ERROR_DMA (0x00000010U) /*!< DMA transfer error */

 

Note How to insert source code.

> Please let me know if my understandings are correct.

These are correct.

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