UART data receive acknowledgement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-14 09:50 AM - edited ‎2024-03-14 09:51 AM
Two devices A & B are communicating on UART. A sends data stream to B. B sends one byte data back to A to acknowldge that data has been received.
I want to implement if A doesn't receive acknowledgement from B then it display Error message on LCD.
Please suggest best logic in A to implement this.
As far I think I should start the UART_Receive_IT API for one byte . and complete callback sets the flag for acknowlegement. Incase flag is not set within one second or so after sending data then A display Error message on LCD. Should I start HAL_Delay(1000) after sending data and then check for flag set or not?
If anyother best way, kindly suggest.
I am still relatively new to coding word..so trying to find best ways.. ;)
Solved! Go to Solution.
- Labels:
-
STM32F4 Series
-
UART-USART
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-14 10:29 AM
The blocking HAL_UART_Receive() API takes a timeout:
the non-blocking HAL_UART_Receive_IT() doesn't:
Using HAL_Delay() effectively makes your code blocking - so there seems no point in using the non-blocking API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-14 10:24 AM
>>Should I start HAL_Delay(1000) after sending data and then check for flag set or not?
No, you'd do better taking a TickCount, say HAL_GetTick(), and use that to determine if enough time has expired without getting a callback with the acknowledgment byte
If it responds more quickly you can proceed to do other things.
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
‎2024-03-14 10:29 AM
The blocking HAL_UART_Receive() API takes a timeout:
the non-blocking HAL_UART_Receive_IT() doesn't:
Using HAL_Delay() effectively makes your code blocking - so there seems no point in using the non-blocking API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-14 10:49 AM
Cool,
So after sending data , i run the blocking HAL_UART_Receive()with timeout of say 1 second and then check the HAL_StatusTypeDef return.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-14 11:04 AM
Yes.
And, of course, check the received character (if any) - to make sure it's the correct acknowledgement.