cancel
Showing results for 
Search instead for 
Did you mean: 

Stuck in UART_WaitOnFlagUntilTimeout HAL lib

kecskesgery
Associate II
Posted on January 04, 2016 at 18:38

Hello there!

I'm trying to communicate with the STM spwf01sa wifi module via UART. At first, it works for about 10-15 minutes, then the software stucks, right after the HAL_UART_Receive, in theUART_WaitOnFlagUntilTimeout function. What is actually happening, is that it never quits the while loop, because, for some reason, the HAL_GetTick()'s value wont change (HAL_Init gets called up uppon software start).

static HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Timeout)
{
uint32_t tickstart = 0;
/* Get tick */ 
tickstart = HAL_GetTick();
/* Wait until flag is set */
if(Status == RESET)
{
while(__HAL_UART_GET_FLAG(huart, Flag) == RESET)
{
/* Check for the Timeout */
if(Timeout != HAL_MAX_DELAY)
{
if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
{
/* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */

See, because the last IF condition never recieves true value, the whole wait cycle wont quit this way. My question is that, is it a known issue, a bug in the Cube lib? Or can I bypass it somehow? Also, why does not work the HAL_GetTick function? Thanks for the help in advanced! #uart #irq #clive1 #uartwait
13 REPLIES 13
al.1
Associate

Disable overrun. That solves it. This bug is still in the most recent version.

Hi, how do i disable overrun?

Sorry, don't know this for HAL, but for LL it's: LL_USART_DisableOverrunDetect(USARTx)

BRutt.1
Associate

I was able to solve my issue by updating the stm32f4xx_hal_msp.c. Make sure the peripherals are being enabled correctly.