HAL_UART_Transmit_IT blocks until end of transmission
I am using STM32CubeIDE + STM32F103C8T6 MCU with USART1. I am transmitting data by calling this function:
HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef * huart, uint8_t * pData, uint16_t Size)The function is generated by CubeIDE. It turns out that this call blocks until the last character is sent out. I found that what is blocking is the following line in this function:
__HAL_UART_ENABLE_IT(huart, UART_IT_TXE);HAL_UART_TxCpltCallback is called some microseconds before HAL_UART_Transmit_IT returns.
Any ideas why this happens? I would expect HAL_UART_Transmit_IT to return immediately, while transmitting the data should be done in the background.
