Issue getting all data over USART with LL API LL_USART_ReceiveData8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-29 3:12 PM
Hi,
I am using STM32F407VET6 MCU and trying to receive data using LL API LL_USART_ReceiveData8 over USART configured as modbus.
I confirmed USART transmit (
I also confirmed other receiving device also sending a 8 byte response back. (Confirmed via Modbus app)
But on the STM32F407VET6 MCU side I am just receiving 1 byte of data.
Note - If I don't insert delay (LL_mDelay) I only get first byte, if I add delay I only get 2nd byte.
After receiving one byte , its just forever waiting on LL_USART_IsActiveFlag_RXNE (never comes out of while loop).
Based on online search I see lots of folks are seeing the same problem (
- Labels:
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-29 3:18 PM
You probably want to pay attention to receive and transmit concurrently and not block, as both things can and do happen at once.
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-02-29 4:28 PM
Can you please elaborate ? Is there any code change recommendations compared to what I posted ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-03 5:21 AM
Consider what is happening on the line. When you send 8 characters, your code is inside LL_USART_Transmit. It is not reading character coming in. So when characters are sent back, and you're still within the sending code, they are missed. UART reception is typically done best in a non-blocking manner such as using HAL_UART_Receive_IT or HAL_UART_Receive_DMA or HAL_UARTEx_ReceiveToIdle_*.
