Question
HAL_UART_Receive_IT not resetting after HAL_UART_Transmit
I am trying to implement MODBUS protocol. STM32 receives an initial message of 8 bytes and then send a response of 8 bytes. However, the next message received by the STM32 doesn't trigger the HAL_UART_Receive_IT callback.
uint8_t reception_complete = FALSE; // turns true when a MODBUS command is received
uint8_t response[8];
uint8_t response_ready = FALSE;
int main(void)
{
while (1)
{
// Hang until a MODBUS message is received (8 bytes)
while(reception_complete != TRUE)
{
HAL_UART_Receive_IT(&huart2, &recvd_data, 1);
if (response_ready == TRUE)
{
//send the response back to the master (blocking mode)
uint16_t resp_len = sizeof(response);
HAL_UART_Transmit(&huart2, (uint8_t*)response, resp_len, HAL_MAX_DELAY);
response_ready = FALSE;
}
}
}
}

