Electrical – Possibility for UART receive data loss

halinterruptsstm32uart

In a lot of examples using STM32, HAL, where UART data is received by interrupt the code looks like:

Initially (to start the receiving):

HAL_UART_Receive_IT(&huart1, Rx_data, 1);            

When an interrupt receive is complete:

//Interrupt callback routine
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)  
{
    ...
    HAL_UART_Receive_IT(&huart, Rx_data, 1);            
}

I am wondering, is there a possibility that bytes are lost between the actual receiving and after the (receive complete) callback where the interrupt is started again.

Or is it assumed the interrupt handler above is so short the data will still be in the UART buffer?

Best Answer

H/W flow control between UART's RTS/CTS with 16 byte Rx buffers are intended to prevent overflow. But it useful to include parity to improve signal integrity in case flow control latency is too long.

When demanding low error rates with software retry or data filtering or testing max data rates in noisy environments, it is useful to enable parity.

It is also beneficial to check for ; stop bit errors, buffer overflow errors and test with simulated environmental noise. (ESD, RF pulses , SMPS CM noise etc. lack of earth grounds etc. )