cancel
Showing results for 
Search instead for 
Did you mean: 

ORE flag of USART_ISR is not being cleared by HAL layer in STM32-Nucleo-H7A3Zi dev-kit.

Axay
Associate II

Hi community. Greetings of the day!

I'm using ThreadX RTOS thread to receive the data from USART and I'm sending it to the ThreadX queue & transmitting it to the USART(Tera-term display).

What happening is that I'm using IT(interrupt) method to receive data, whenever I'm entering data manually(by typing) data is coming properly and everything works as expected. Whenever I paste something then USART Overrun error occurs and everything stops, like I can't enter any character once Overrun happens. And I have to reset the controller as well.

NOTE: Whenever I paste something having large length then only few of the characters are being considered by the USART Interrupt API and then USART Overrun error occurs.

Execution even goes to the HAL_UART_IRQHandler() function and inside it's also checking for Overrun error and if it happened so then it's clearing the ORE flag as well by setting the ORECF flag of USART_ICR(USART Interrupt) control register.

Attaching the code snippet, any help will be appreciated. Thanks in advance!

/*<!-- checking this particular thing inside HAL_UART_IRQHandler() method>*/
    /* UART Over-Run interrupt occurred -----------------------------------------*/
    if (((isrflags & USART_ISR_ORE) != 0U)
        && (((cr1its & USART_CR1_RXNEIE_RXFNEIE) != 0U) ||
            ((cr3its & (USART_CR3_RXFTIE | USART_CR3_EIE)) != 0U)))
    {
    	SET_BIT(huart->Instance->ICR, UART_CLEAR_OREF); //set the ORECF bit to clear the ORE
bit
    	READ_REG(huart->Instance->RDR); //read the RDR register
      __HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
 
      huart->ErrorCode |= HAL_UART_ERROR_ORE;
    }

2 REPLIES 2
TDK
Guru

If you're encountering an overrun, the code can't keep up with data coming in. There is no simple fix for this--the solution would be to improve code speed or to use something like DMA that you poll occasionally.

Although given the speed of UART, an interrupt based solution should be viable.

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

@TDK​ Thankyou for the answer.

Regards,

Axay