Skip to main content
Dick Lin
Senior
May 24, 2018
Question

HAL_UART_Receive() timeout issue

  • May 24, 2018
  • 1 reply
  • 1507 views
Posted on May 24, 2018 at 20:40

Hi,

I am using Nucleo-144 board connecting UART to my TI device using 250000 baudrate. I always got timeout no matter what timeout using.

Seems the issue is 

UART_WaitOnFlagUntilTimeout() failed and return HAL_TIMEOUT.

if(UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)

{

return HAL_TIMEOUT;

}

  while((__HAL_UART_GET_FLAG(huart, Flag) ? SET : RESET) == Status)

#define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))

Above are the code checking timeout. 

Reading the HAL user's manual, seems HAL_UART_Receive() need to enable FIFO mode. Is there any reference code to enable FIFO mode or DMA mode? I am using the Cube generated code, and reference to other code. Haven't found any useful example yet.

Thanks,

Dick

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    May 24, 2018
    Posted on May 24, 2018 at 21:16

    Suggests it's not actually receiving any usable data, or the ISR is flagging one or more receive errors that need to be cleared.

    A basic test would be to loop the TX pin into the RX pin, sending data in the correct form and seeing it be received.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Dick Lin
    Dick LinAuthor
    Senior
    May 24, 2018
    Posted on May 24, 2018 at 21:34

    I am able to transmit data using HAL_UART_Transmit() function and confirmed the tx/rx data from logic analyzer. Just not get the correct data from HAL_UART_Receive().

    Tesla DeLorean
    Guru
    May 24, 2018
    Posted on May 24, 2018 at 21:43

    So look at the USART registers, and reported status/errors. Don't park a debugger 'peripheral view' over the USART register. Read them and print them out a different USART or SWV debug output.

    Look at the pin configurations and clocks. Check the RCC and GPIO register bits.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..