Question
Over run error when using HAL_UART_Receive_IT
Posted on April 19, 2016 at 16:42
Hi,
I want my board communicate with a module in uart interruption.STD_ERROR_t SendCmdToNemeus(UART_HandleTypeDef *huart, uint8_t *cmd, uint16_t ans_size, uint8_t *answer_buffer){
STD_ASSERT_PTR(huart);
STD_ASSERT_PTR(cmd);
STD_ASSERT_PTR(answer_buffer);
STD_ASSERT_UINT16(ans_size, 0, 150);
HAL_StatusTypeDef halstatus=HAL_OK;
STD_ERROR_t stdstatus=STD_ERROR_OK;
uint32_t notificationReceived = 0;
uint8_t buffer[300]={0};
/* clear the RX buffer befor send cmd*/
while(HAL_UART_Receive(huart,answer_buffer, 1,1000)!= HAL_TIMEOUT) {
;
}
/* Answer reception*/
if(HAL_OK != (halstatus = HAL_UART_Receive_IT(huart, answer_buffer, 25))){
stdstatus=CheckCodeError(halstatus);
}
/* Command transmission*/
if(HAL_OK != (halstatus = HAL_UART_Transmit_IT(huart,(uint8_t*)cmd , strlen((char *)cmd)))){
stdstatus=CheckCodeError(halstatus);
}
/* Wait for notification (end of transmission) to unblock task*/
while (UartReadyRx != SET || UartReadyTx != SET)
{
}
UartReadyRx = RESET ;
UartReadyTx = RESET ;
stdstatus=STD_ERROR_OK;
return stdstatus;
}
First time I send command it s working well but the second one make my code going to thevoid HAL_UART_ErrorCallback(UART_HandleTypeDef *UartHandle); instead of
the reception callback :
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
{
/* Set transmission flag: trasfer complete*/
if(UartHandle->Instance==USART2){
UartReadyRx = SET;
}
}My board doesn't support Hardware Flow control and the module send lot of **** unexpected charaters.
Is that the issue? Thx #hal_uart_recei #stm32 #over-run