title: STM32: Receiving data via USART
body: <p>I'm working on STM32 Discovery (F10x family), and I'm trying to send and receive data through USART1.</p>
  
  <pre><code>int uart_putc(int c, USART_TypeDef* USARTx)
  {
      assert_param(IS_USART_123_PERIPH(USARTx));
  
      while (USART_GetFlagStatus(USARTx, USART_FLAG_TXE) == RESET);
      USARTx-&gt;DR =  (c &amp; 0xff);
      return 0;
  }
  
  int uart_getc (USART_TypeDef* USARTx)
  {
      assert_param(IS_USART_123_PERIPH(USARTx));
  
      while (USART_GetFlagStatus(USARTx, USART_FLAG_RXNE) == RESET);
      return  USARTx-&gt;DR &amp; 0xff;
  }
  </code></pre>
  
  <p><code>uart_putc</code> works finely but uart_getc gets stucked in the while loop, it seems like the while condition is never true.<br>
  Does someone know what is wrong with this code?</p>