cancel
Showing results for 
Search instead for 
Did you mean: 

HAL, UARTs and overrun errors

hbarta2
Associate III
Posted on December 17, 2014 at 17:42

Platform: STM32F429I-Discovery and Discovery-WiFi connected to UART1

Tools: IAR EWARM (eval until we get the license) Situation: If I pull power from the WiFi board and plug it back in,. this apparently results in an overrun in the UART. Not too surprising as the other board powers up while the STM32F429I-Discovery tries to read/write. This is configured by HAL for interrupt driven input. In the procedure

void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)

in

stm32f4xx_hal_uart.c

the following code exists to handle overrun interrupts:

tmp1 = __HAL_UART_GET_FLAG(huart, UART_FLAG_ORE);
tmp2 = __HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR);
/* UART Over-Run interrupt occurred ----------------------------------------*/
if((tmp1 != RESET) && (tmp2 != RESET))
{ 
__HAL_UART_CLEAR_OREFLAG(huart);
huart->ErrorCode |= HAL_UART_ERROR_ORE;
}

I've stepped through the code and it steps over

__HAL_UART_CLEAR_OREFLAG(huart).

As aresultthe interrupt does not get cleared.

Status flags in 'huart' areHAL_UART_STATE_READY for State and forHAL_UART_ERROR_ORE. What's the best way to fix this? I'm, inclined to copy this ISR into a project file and tweak it as needed to solvethisproblem (doing whatever is needed to get my copy of the ISR linked to the interrupt.) But I'm open to suggestions if there is a better strategy. If we agree that this is a bug, is there an appropriate place to file a bug report? Thanks! #hal-uart-overrun
5 REPLIES 5
Posted on January 12, 2015 at 16:37

Hi,

Please check the UART baud rate configuration, you should set the same baud rate configuration used by your WiFi board, If the baud rate gap between Discovery and WiFi Boards is higher, you will continue to receive the OVR error even after performing the clear using the macro:

__HAL_UART_CLEAR_OREFLAG(huart)

Regards, Heisenberg.
hbarta2
Associate III
Posted on January 13, 2015 at 20:52

Hi Heisenberg,

Many thanks for the suggestion. I'm working on a different part of the project right now but hope to return to this soon.  I will check the baud rate.

This is the UART connection to the Discovery-WiFi, BTW, which runs at 921600 baud. :o It strikes me as a pretty high baud rate for character by character interrupts but I don't really have a good feel for how fast this processor is.

best,

hank
vrouesnel
Associate II
Posted on March 02, 2015 at 13:10

Hi Hank,

I am having the same problem. Did you find a fix?

ersan
Associate II
Posted on March 03, 2015 at 22:49

Problem is easy to solve... take a look on your HAL Interrupt Handler for the U(S)ART. It is totally overloaded. Just clear everything out and keep a code that moves the usart received data to ur buffer and clear the interrupt flag. - nothing more else

hbarta2
Associate III
Posted on March 09, 2015 at 21:04

Our 'fix' was to switch to SPI. At least the master doesn't hang waiting for data from the slave.