title: UART Receiving keyboard input doesn't work
body: <p>I am having trouble with reading data sent from my laptop to the microcontroller via <strong>UART</strong>. The transmitting part works fine - I can send data to my laptop without problems, but echoing data, or reading keyboard input data from the laptop doesn't work. I have tried to implement reading both with polling and with Rx interrupt routines, but without success. The microcontroller I am using is <strong>ATMEGA2560</strong>, and I am conntected to my laptop via <strong>FTD1232</strong> USB to TTL serial converter.</p>
  
  <p>I am using <strong>Putty</strong> as a serial comm terminal, and the <strong>Arduino IDE</strong> for programming.</p>
  
  <p>I am assuming that the problem is not in the hardware based on the following - I have tried initializing different USARTs and tried to use different COM ports, as well as another USB to TTL converter, various wires, but the result is the same. I have also connected another power source to supply enough voltage to all devices.</p>
  
  <p>I am trying to get at least a response by turning a LED on when Rx interrupt occurs (when I type something in the terminal).</p>
  
  <p>~</p>
  
  <pre><code>#define F_CPU 16000000UL //16MHz
  #define BAUD 115200UL //bps
  #define BAUD_PRESCALER (((F_CPU/(BAUD*8UL)))-1) //Table 101, page 212
  
  volatile uint8_t temp;
  
  void UART_init(){
    //Set baud rate
    UBRR0H = (uint8_t)(BAUD_PRESCALER &gt;&gt; 8); //Higher portion of the baud rate
    UBRR0L = (uint8_t)BAUD_PRESCALER; //Lower portion of the baud rate
  
    //Enable Receiver and Transmitter
    UCSR0B = (1 &lt;&lt; RXEN0) | (1 &lt;&lt; TXEN0);
    //Set frame format: 8-bit format, 1 stop bit, no parity
    UCSR0C |= (3 &lt;&lt; UCSZ00);
    UCSR0C &amp;= ~(1 &lt;&lt; USBS0); //clear for 1 stop bit
  
    //Set Double Speed Asynchronous mode
    UCSR0A |= (1 &lt;&lt; U2X0);
  
    UCSR0B |= (1 &lt;&lt; RXCIE0); //Enables interrupt rxc
  }
  
  uint8_t UART_getchar(){
    //Wait for RXC flag
    while(!(UCSR0A &amp; (1 &lt;&lt; RXC0))){};
    return UDR0;
  }
  
  //Arduino setup()
  void setup(){
    pinMode(8, OUTPUT);
    UART_init();
    sei();
  }
  
  //Arduino loop()
  void loop(){
    delay(500);
    UART_putchar('a');
  }
  
  ISR(USART0_RX_vect){
    temp = UDR0;
    digitalWrite(8, HIGH);
  }
  </code></pre>
  
  <p>It is a lenghty post, but I tried to be specific and also post the whole code. The datasheet I am using for the ATMEGA2560 can be found <a href="http://pdf1.alldatasheet.com/datasheet-pdf/view/175205/ATMEL/ATMEGA2560-16AU.html" rel="nofollow">here</a>.</p>
  
  <p>My Putty settings:</p>
  
  <p><a href="http://i.stack.imgur.com/1vagg.png" rel="nofollow">COM Port Settings</a></p>