HAL_UART_Receive() timeout issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-24 11:40 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-24 12:16 PM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-24 2:34 PM
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().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-24 2:43 PM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-05-24 6:29 PM
I got it now, need to clear some flags. Thx
__HAL_UART_CLEAR_OREFLAG(m_uart_handler);
__HAL_UART_CLEAR_NEFLAG(m_uart_handler);