cancel
Showing results for 
Search instead for 
Did you mean: 

Instant overrun when enabling via HAL_UART_Receive_IT

jasonp4113
Associate II
Posted on August 07, 2014 at 07:13

Hi all,

I had an overrun error issue between successive calls to 'HAL_UART_Receive_IT()'.

I know what causes the overrun, but shouldn't the following lines be added to HAL_UART_Receive_IT() to clear any pending error bits before re-enabling the ISR? 

tmp = huart->Instance->SR;

tmp = huart->Instance->DR;

Jason
3 REPLIES 3
Posted on September 10, 2014 at 11:47

Hi Jason,

The clear for the pending interrupts is not part for the UART receive process and it depends on the user application. In oreder to clear the pending interrupts we provide a specific macros in stm32f4xx_hal_uart.h file that can be used directly by the application (when needed). Please refer to the Exported macro section in stm32f4xx_hal_uart.h file.The specific macro to clear the overrun pending interrupt is

__HAL_UART_CLEAR_OREFLAG()

Thus you can perform this to avoid overrun issue:

__HAL_UART_CLEAR_OREFLAG(…)
HAL_UART_Receive_IT(…)

PS: Only the macro start by the prefix “__HAL_�? can be exported.

Regards.
jasonp4113
Associate II
Posted on September 23, 2014 at 09:53

Perfect! Didn't know these macros existed....

I really hate the idea of modifying HAL drivers...

Posted on September 23, 2014 at 10:51

Great ! Do, click ''Mark as helpful post 0690X00000605UvQAI.png'', if any of my replies helps solve your problem.

Regards,

Heisenberg.