My question is manly regarding this function in ArduinoCore-avr:
https://github.com/arduino/Ardui...
size_t HardwareSerial::write(uint8_t c)
I can see that it moves the input character into the buffer:
_tx_buffer[_tx_buffer_head] = c;
2 questions arise:
1- What is the tx buffer? I'm using this page to read over the details of UART:
http://www.avrbeginners.net/arch...
Is the tx buffer the same the UDR Data Register? or is it just a temp location in memory?
2- How is the data actually transferred out the pin?
In code I can see this snippet at the very end:
sbi(*_ucsrb, UDRIE0);
Which basically sets the "UDRIE" pin to 1. Above link has this explanation:
If this bit is set, an interrupt occurs if UDR is empty. That allows writing the next byte to UDR while the currently being sent byte is still in the shift register.
I still don't fully get it. So setting UDRIE to 1 makes data in "_tx_buffer" move into UDR? then from there how does it move to the shift register?
Then once it is moved into the shift register does it atomically get transmitted on each clock cycle?