2016-04-19 07:42 AM
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-run2016-04-19 12:41 PM
Is it a valid overrun error? You might need to clear the overrun flag yourself. I do this in the uart receive interrupt. Not clearing the overrun flag prevents later character available ints from firing.
From: pwdusid Posted: Tuesday, April 19, 2016 4:42 PM Subject: Over run error when using HAL_UART_Receive_ITFirst 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? Thx2016-04-19 12:42 PM
Is it a valid overrun error? You might need to clear the overrun flag yourself. I do this in the uart receive interrupt. Not clearing the overrun flag prevents later character available ints from firing.
From: pwdusid Posted: Tuesday, April 19, 2016 4:42 PM Subject: Over run error when using HAL_UART_Receive_ITFirst 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? Thx2016-04-19 12:42 PM
Is it a valid overrun error? You might need to clear the overrun flag yourself. I do this in the uart receive interrupt. Not clearing the overrun flag prevents later character available ints from firing.
From: pwdusid Posted: Tuesday, April 19, 2016 4:42 PM Subject: Over run error when using HAL_UART_Receive_ITFirst 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? Thx2016-04-20 01:12 AM
2016-04-20 02:27 PM
I don't know the hardware you are using but the HAL code generated for mine disables the rx interrupts after the callback is executed (or an error occurs), so you have to call HAL_UART_Receive_IT again to be able to receive more data. If you don't and you send it more data without clearing the data register, the overrun occurs
2023-08-21 12:13 AM
2023-08-21 06:58 AM
Hello @Mr._Nileshkumar_Solanki
Would you please start a new question. Provide more details about your issue.
Thanks
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.