I was reading documentation on UART on AVR and it looks simple: when a flag (bit RXC0
of register UCSR0A
) is set to 1, it means the micro controller has new data for you, and you read this from register UDR0
.
But something boggles my mind: How does the micro controller know that we have read the data? Or, in other words, after it received the first byte on UART, the flag is set to 1, but when is it set back to 0?
UDR0
register is hardwired, so that when it is read (and the "READ" line goes active) then the "latch" on theRXC0
flag is cleared (by the same "READ" line going active). Have a look at some UART design documents, and/or "State Machines". – Greenonline Jan 3 '16 at 16:33