Question
HAL_UART_Receive_IT returns error
Posted on August 04, 2016 at 09:48
Hi, I want to transmit something from PC to uC and I put UART in receive mode. However HAL_UART_Receive_IT keeps returning error, and I don't know why?
My code is really simple:int main(void)
{/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART2_UART_Init(); while (1) { uartStatus = HAL_UART_Receive_IT(&huart2, (uint8_t *)aRxBuffer, 10); if(uartStatus != HAL_OK) { Error_Handler(); } } }void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
{ /* Set transmission flag: transfer complete */ } I let the code rund and did not send anything from PC. After a few loop cycles, the uartStatus becomes BUSY and error_handle() occurs. How to solve this problem ? Thanks Bien