Skip to main content
Andrew Neil
Super User
June 17, 2024
Question

Behaviour of HAL_UART_ErrorCallback

  • June 17, 2024
  • 9 replies
  • 2373 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.

9 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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Andrew Neil
Super User
June 18, 2024

Both - started by looking at the code, then tested

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Pavel A.
June 18, 2024

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

Sure enough. No good deed goes unpunished.