AnsweredAssumed Answered

HAL_UART_Receive_IT returns error

Question asked by le.bien on Aug 4, 2016
Latest reply on Aug 22, 2016 by FTITI.Walid
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

Outcomes