2020-08-14 03: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
2020-08-16 03: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
2020-08-17 04:39 PM
Right, but I know when the data comes in