2024-02-29 03: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 (
2024-02-29 03: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.
2024-02-29 04:28 PM
Can you please elaborate ? Is there any code change recommendations compared to what I posted ?
2024-03-03 05: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_*.