title: Why am I receiving random characters in uart?
body: <p>I am editing the question to make it clear.</p>
  <p>So I have a  naze32 rev6 board, I am trying to write custom firmware to the board. I am currently testing UART purpose being when I write drivers for sensors I can use UART to send the sensor data to PC via serial communication.</p>
  <pre><code>  HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    MX_USART1_UART_Init();
  
    uint8_t Message[] = &quot;Hello, World!!&quot;;
    for(;;)
    {
        HAL_UART_Transmit(&amp;huart1, Message, sizeof(Message), HAL_MAX_DELAY);
        HAL_Delay(1000);
    }
  }
  
  static void MX_USART1_UART_Init(void)
  {
    huart1.Instance = USART1;
    huart1.Init.BaudRate = 115200;
    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><a href="https://i.stack.imgur.com/lzB1J.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I am attaching the screenshot of my putty settings.</p>
  <p>this is what i receive.</p>
  <blockquote>
  <p><code>|▒*▒▒*R▒</code>|▒<em>▒▒</em>R▒<code>|▒*▒▒*R▒</code>|▒<em>▒▒</em>R▒<code>|▒*▒▒*R▒</code>|▒<em>▒▒</em>R▒<code>|▒*▒▒*R▒</code>|▒<em>▒▒</em>R▒<code>|▒*▒▒*R▒</code>|▒<em>▒▒</em>R▒<code>|▒*▒▒*R▒</code>|▒<em>▒▒</em>R▒`|▒<em>▒▒</em>R▒</p>
  </blockquote>
  <p>Note -</p>
  <p>If I use below LL firmware the serial port works fine.</p>
  <pre><code>#include &quot;stm32f10x.h&quot;
  
  int main (void)
  {
  
      RCC-&gt;APB2ENR |= (RCC_APB2ENR_USART1EN | RCC_APB2ENR_IOPAEN);
      
      GPIOA-&gt;CRH |= (GPIO_CRH_MODE9 | GPIO_CRH_CNF9_1);
      GPIOA-&gt;CRH &amp;= ~(GPIO_CRH_CNF9_0);
      
      USART1-&gt;BRR = 0x1D4C;
      USART1-&gt;CR1 |= (USART_CR1_UE | USART_CR1_TE | USART_CR1_RE);
      
      for(;;)
      {
          if(USART1-&gt;SR &amp; USART_SR_RXNE)
          {
              char temp = USART1-&gt;DR;
              USART1-&gt;DR = temp;
              while(!(USART1-&gt;SR &amp; USART_SR_TC));
          }
      }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/B12dX.png" rel="nofollow noreferrer">enter image description here</a></p>