Hi all, A little technical question that came up while I was reading Arduino's Serial source code.
I can write, for example, Serial.begin(110) and get an appropriate signal from Serial.write(...).
In the HardwareSerial::begin method, the code goes like this:
[...] baud_setting = (F_CPU / 8 / baud - 1) / 2;
For 110, on a 16MHz Arduino, the result should be 9090. This goes into the UBRRn register pair:
*_ubrrh = baud_setting >> 8; *_ubrrl = baud_setting;
So far so good. However, in the ATmega328 datasheet, it states that UBRRn is only 12 usable bits, i.e. up to 4095. The rest of the bits are "reserved for future use [...] these bit [sic] must be written to zero when UBRRnH is written." (page 205).
So, how does 9090 fit into 4095? :)