AnsweredAssumed Answered

STM32F4 HAL USART Interrupt over run error

Question asked by pinkman on Mar 2, 2015
I am trying to receive GPS data over USART. I previously attempted "polling mode" which produced garbled/corrupted output. Now trying interrupt mode without success. I am also using FreeRTOS.


```
#define RXBUFFERSIZE 1
uint8_t aRxBuffer[RXBUFFERSIZE];


int task() {


  status = HAL_UART_Receive_IT(&huart1, (uint8_t *) aRxBuffer, RXBUFFERSIZE);
  if (status != 0) __BKPT(0);


}


extern "C" {


void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
  HAL_StatusTypeDef status;
  uint8_t data;
  osMessagePut(usartQueue, aRxBuffer[0], 0);
  status = HAL_UART_Receive_IT(&huart1, (uint8_t *) aRxBuffer, RXBUFFERSIZE);
  if (status != 0) __BKPT(0);
}


}

```


When `HAL_UART_IRQHandler(UART_HandleTypeDef *huart)` is called from the interrupt callback, the the over run error occurs which is the result of this code:


```
  tmp1 = __HAL_UART_GET_FLAG(huart, UART_FLAG_ORE);
  tmp2 = __HAL_UART_GET_IT_SOURCE(huart, UART_IT_ERR);
  /* UART Over-Run interrupt occurred ----------------------------------------*/
  if((tmp1 != RESET) && (tmp2 != RESET))
  { 
    __HAL_UART_CLEAR_OREFLAG(huart);
    
    huart->ErrorCode |= HAL_UART_ERROR_ORE;
  }
```



What could be the cause?


Thank you :)

Outcomes