I want to establish a communcation between my ATmega32A and PC but there's a line that I don't understand. The datasheet says that:"When data comes in,the RXC0 bit in UCSR0A will be set,and you can read the incoming data out of UDR0

The function to receive byte looks like this:

unsigned char USART_receive(void)
   while(!(UCSRA & (1<<RXC)));
   return UDR;

What I understand from this:We wait until all the bits are inside of the UDR register and when the RXC turns to 0 we gonna return UDR register. Can someone clarify me if I'm right or not?

  • 1
    \$\begingroup\$ Mostly correct in concept, only the bits are received into a different register and then transferred as a complete word into the register you read from. Otherwise you'd have very little time to claim the data before it became corrupted by the first bit of the next word. Some UARTs can optionally insert a multi-word FIFO buffer there, but it's very rare to find one that doesn't at least make the distinction between the shift register and the access register. \$\endgroup\$ Mar 20, 2018 at 18:14

1 Answer 1


This while(!(UCSRA & (1<<RXC))); means you wait until the RXC bit is SET (turn to 1), in the UCSRA register. When this bit is SET (turn to 1 from 0), it means your UDR register has completed receiving a byte of data.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.