#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>

unsigned char word=0x00;

ISR(USART_RXC_vect)
{
 cli();
/*---------------------------*/

/*
 unsigned char status;
 
 status=UCSRA;
 if(status & (1<<FE)|(1<<DOR)|(1<<PE))
 {
  while(UCSRA&(1<<RXC))status=UDR;
  return;
 } 
*/
 
 word=UDR;

 
/*---------------------------*/
 sei();

 return;
}

int main(void)
{
 /*Port C - LEDs*/
 DDRC=0xFF;
 PORTC=0x00;

 /*Speed: 9600 BOD*/
 UBRRH=0;
 UBRRL=51;

 /*Inicial UCSRA*/
 UCSRA=0x00;

 /*UCSRB*/
 UCSRB=0x00;
 UCSRB=(1<<RXCIE)|(1<<RXEN);

 /*UCSRC: 8 bit;*/
 UCSRC=(1<<URSEL)|(1<<USBS)|(1<<UCSZ1)|(1<<UCSZ0);

 sei();

 while(1)
 {
   PORTC=word;

   _delay_ms(10);
 }

 return 0;
}
