HAL Delay () function does not work with HAL_UART_Receive()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-14 3:50 PM
Hi everyone
I'm having this problem while using stm32L073RBT:
When I use HAL_UART_Receive() only it seems normal, but when I use HAL Delay () after or before HAL_UART_Receive() the program freezes,Knowing that I did not enable any interrupt!!
Thanks
- Labels:
-
STM32L0 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-16 3:31 PM
Hmm, what exactly do you expect from your main loop code?
while (1) {
HAL_UART_Receive(&huart1,buf,200,500);
HAL_Delay(500);
i++;
}
From my point of view your code puts the UART into receive mode for 500ms, then sleeps for another 500ms without being able to receive data. This may work or not, it's a question of chance if you are in receive mode when you transmit your test data. By removing the delay function you just increase the chance for successful reception.
Take a look at HAL_UART_Receive_DMA() or HAL_UART_Receive_IT() functions instead to receive data in the background of your main program execution.
HTH,
Tobias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-08-17 4:39 PM
Right, but I know when the data comes in

- « Previous
-
- 1
- 2
- Next »