Hello,
I working with an ATMEGA 16. I am trying to transmit and receive data using the USART and hyperterminal. I have had no trouble initializing the USART or transmitting data. In fact, I've done a dozen projects using the transmit function. But I'm not having any luck when I try to receive data from the keyboard. If I press one or two keys, I get nothing. If I keep trying, hyperterminal locks up. I've taken my code directly out of the ATMEGA 16 manual. My two subroutines are shown below.
#define UDRE 5
#define RXC 7
void transmit(unsigned char data)
{
while(!(UCSRA & (1<<UDRE)))
;
UDR=data;
}
unsigned char receive(void)
{
while(!(UCSRA & (1<<RXC)))
;
return UDR;
}
Does anyone have any idea why these simple subroutines wouldn't work?
thanks,
andy