Skip to main content
Super User
June 17, 2024
Question

Behaviour of HAL_UART_ErrorCallback

  • June 17, 2024
  • 2 replies
  • 2323 views

It seems that, if an error occurs on the last (or only) byte of a HAL_UART_Receive_IT transfer, the HAL_UART_ErrorCallback will not be called until after the HAL_UART_RxCpltCallback - is that right?

STM32F0 Cube package.

    This topic has been closed for replies.

    2 replies

    ST Employee
    June 18, 2024

    Hello @Andrew Neil ,

    can you give us the reason behind this conclusion was it found by testing, or this was concluded after the examination of HAL implementation?

    Regards

    Super User
    June 18, 2024

    Both - started by looking at the code, then tested

    ST Employee
    June 18, 2024

    Hello @Andrew Neil ,

    From a Hardware point of view, I think booth events are not related:

    STea_0-1718717377256.png

    but in the HAL implementation the enable of the UART Error Interrupt: (Frame error, noise error, overrun error) is inside the UART_Start_Receive_IT maybe try to set this bit before entering the interrupt and you should be able to detect errors once the HAL_UART_IRQHandler is called we test if error accrued if this bit set and not cleared this on the entry of the function :

    if ((errorflags != 0U)
     && (((cr3its & USART_CR3_EIE) != 0U)
     || ((cr1its & (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_RTOIE)) != 0U)))

    Regards

    Super User
    June 18, 2024

    >I'll have to make an example ...

    Sure enough. No good deed goes unpunished.