title: STM32F1 problem receiving duplicated first byte on USART
body: <p>I have a problem with an STM23F103 I'm using UART to transmit and receive data.the data is sent and another board replies. I can see the communication with a Logic Analyzer which looks fine on it.but the received data on STM32 have the first byte either from the first byte of the packet send or from last byte of the last received packet.I don't know what's wrong with my code but I can't figure out how to solve the issue</p>
  <p>Here is the code in the main</p>
  <pre><code>uint8_t b[5] = {0xAA,0xBB,0xCC,0xDD,0xEE};
  HAL_UART_Transmit(&amp;huart3,b, sizeof(b), 100);
  uint8_t r[5]={0,0,0,0,0};
  HAL_UART_Receive(&amp;huart3, r, sizeof(r), 100); 
  HAL_Delay(100);
  uint8_t d[5] = {0x11,0x22,0x33,0x44,0x55};
  HAL_UART_Transmit(&amp;huart3,d, sizeof(d), 100);
  uint8_t r2[5]={0,0,0,0,0};
  HAL_UART_Receive(&amp;huart3, r2, sizeof(r2), 100);
  HAL_Delay(100);
  </code></pre>
  <p>and here the Init</p>
  <pre><code>static void MX_USART1_UART_Init(void)
  {
    huart1.Instance = USART1;
    huart1.Init.BaudRate = 10400;
    huart1.Init.WordLength = UART_WORDLENGTH_8B;
    huart1.Init.StopBits = UART_STOPBITS_1;
    huart1.Init.Parity = UART_PARITY_NONE;
    huart1.Init.Mode = UART_MODE_TX_RX;
    huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    huart1.Init.OverSampling = UART_OVERSAMPLING_16;
    if (HAL_UART_Init(&amp;huart1) != HAL_OK)
    {
      Error_Handler();
    }
  }
  </code></pre>
  <p>The packet that appears on the logic analyzer is 0xA1,B2,C3,D4,E5 but on the STM32 it receives AA,A1,B2,C3,D4 the first byte is always the same as the packet that I sent.but only on the first packet.</p>
  <p>On the other packets are received like this 0xE5,66,77,88,99 while it should be 66,77,88,99,AA  but I get E5 from the last received packet. I thought that that packet has not being received so I thought by increasing the size of r and r2 from 5 to 6 it would solve the issue but it doesn't. I receive AA,A1,B2,C3,D4,E5 for r and 0xE5,66,77,88,99,AA for r2.</p>
  <p>I hope its detailed enough to see the issue.</p>
  <p>I'm using STM32CubeIDE</p>