Few packets are getting missed while reading byte by byte using HAL_UART API's
Hello All,
I have configured UARt for Rx interrupt and in the ISR I am reading the UART byte by byte and sending the same to my terminal using HAL_UART_Receive and Transfer API's.
But if I use HAL_UART API's, few bytes of my data is missed in middle and also if I send continuously the system get stuck after multiple iterations. Below is my code and packet sent,
Packet Sent from terminal: 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x0D
Packets received on terminal: 12345689:
12345689: (here 7 is missed)
void DEBUG_IRQ_Handler(UART_HandleTypeDef *huart)
{
uint32_t isrflags = READ_REG(huart->Instance->SR);
uint32_t cr1its = READ_REG(huart->Instance->CR1);
/* UART in mode Receiver -------------------------------------------------*/
if(((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
{
#if 0
dbg_byetRecvd = (uint8_t)(huart->Instance->DR & (uint8_t)0x00FF);
huart->Instance->DR = (dbg_byetRecvd & (uint8_t)0xFF);
#endif
HAL_UART_Receive(huart, &dbg_byetRecvd, 1, 100);
HAL_UART_Transmit(huart, &dbg_byetRecvd, 1, 100);
return;
}
else
{
// Do nothing as we are not handling any interrupt other than RXNE
}
}
May I know what is the issue with HAL_UART api's here? Because if I am using the code to directly read from the Data Register there is no issue .
Please help to know the issue here and also help how to code using the DR directly with all the flags.
