HAL Timeout on UART Receive
I'm setting up a UART channels to transmit and receive from a slave device.
I have Transmit working as I can see the slave is doing what's asked from the command sent to it.
On each command the slave reply's back with acknowledgement.
When I capture the ACK I get HAL_Timeout
Example
static uint16_t timeout = 25; // milliseconds
static HAL_StatusTypeDef val_tx1, val_tx2; static HAL_StatusTypeDef val_rx1, val_rx2;val_tx1 = HAL_UART_Transmit_DMA(&huart1, buffer, buff_size);
val_rx1 = HAL_UART_Receive(&huart1, rcv1_msg, rcvmsg1_size, timeout);while (HAL_UART_GetState(&huart1) != HAL_UART_STATE_READY){}
The execution is stuck forever in the while loop since the HAL UART state is HAL_TIMEOUT
I actually want to use UART Receive with interrupt which fills the RX buffer and I want to simply parse thru the buffer.
But when I use HAL_UART_Receive_IT() the return is always HAL_UART_STATE_BUSY_RX.
How do I go about fixing this.
Thanks.
#uart-tx #uart-rx #uart-it #stm32-usart #usart-stm32