cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L562 UART Data Rx packet loss

414D414E
Visitor

Hi,

I am using USART4 in STM32L562E-DK eval board. with given configuration.414D414E_0-1757398146959.png

 

In which I am able to transmit the data correctly on TX based on which UART slave device is sending back the 4 bytes ACK and 16 bytes RESPONSE.

Using following code

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
  if (huart->Instance == UART4) // check correct UART
  {
    // Store received byte
    //UART_Print("bytercv\r\n");
    if (rxIndex < RX_BUFFER_SIZE_4)
    {
      rxBuffer4[rxIndex++] = rxData;
    }

    // Check if done
    if (rxIndex >= rxTargetLen)
    {
      rxComplete = 1; // Mark reception complete
    }
    else
    {
      // Keep receiving next byte
      HAL_UART_Receive_IT(&huart4, &rxData, 1);
    }
  }
}
 

I am able to receive the ACK but after some time when I read the RESPONSE there is not data available.

If I am reading only 4bytes of data what happens to remaining data is it loss?

Or I have to use FIFO based UART implementation.

Regards,

Aman 


Edited to apply source code formatting - please see How to insert source code for future reference.

1 REPLY 1
TDK
Super User

> If I am reading only 4bytes of data what happens to remaining data is it loss?

If you don't read out a byte before a new byte comes in, an overrun occurs and the new data will be lost. The peripheral will need to have the OVR flag cleared before it will receive new data.

If you feel a post has answered your question, please click "Accept as Solution".