Can anyone help me to adapt this to Serial1??
while (!(UCSR0A & (1 << UDRE0))) // Wait for empty transmit buffer
UCSR0A |= 1 << TXC0; // mark transmission not complete
while (!(UCSR0A & (1 << TXC0))); // Wait for the transmission to complete
I would like to know what is what
TXCO etc. are the names of the registers and bits within the registers in the MCU. They and their functions are defined the in processor data sheet.
The comments in the code describe the purpose of each line.
Correct answere is:
while (!(UCSR1A & (1 << UDRE0)))
UCSR1A |= 1 << TXC1;
while (!(UCSR1A & (1 << TXC1)));
Not completely correct. This line is more in keeping with the notation and documentation:
while (!(UCSR1A & (1 << UDRE1)))