2022-12-04 10:15 PM
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;
}
2022-12-06 09:31 PM
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.
2022-12-07 11:22 PM
@TDK Thankyou for the answer.
Regards,
Axay