title: Receiving number as string (uart)
body: <p>I'm trying to receive a number through uart which is packed as a string. I'm sending number 1000, so I get 4 bytes + null character. But when I convert the array to number with atoi() and compare the integer with 1000 I don't always get a correct number. This is my interrupt handler function for receiving the number. What could be wrong?</p>
  
  <pre><code>void USART1_IRQHandler(void)
  {
      if( USART_GetITStatus(USART1, USART_IT_RXNE) )
      {
          char t = USART1-&gt;RDR;
          if( (t != '\n' &amp;&amp; t!='\0') &amp;&amp; (cnt &lt; 4) )
          {
              received_string[cnt] = t;
              cnt++;
          }
          else
          {
              cnt = 0;
          }
  
          t = 0;
          received_string[4] = 0;
      }
  
      if(cnt==4)
      {
          data = atoi(received_string);
      }
  }
  </code></pre>