where : ibrtses embedded

# Quartz and baud rates

There are many quarz and resonator frequencies to choose from and there are many baud rates to match. For the usual 8,n,1 line parameters, a baudrate is considered acceptable when the frequency difference is within +-2% of the baudrate.

## Concerning the AVR and the PIC

The AVR have a common quartz frequency to baud rate ratio. It is either
``` for the normal mode:  baud = fosc/(16*(UBRR+1))
for the double speed mode : baud = fosc/(8*(UBRR+1))
with UBRR being the 12bit divisor in the baud rate register
```

The PIC also have a common quartz frequency to baud rate ratio. It can be of
``` for the div 64 mode:  baud = fosc/(64*(n+1))
for the div 16 mode : baud = fosc/(16*(n+1))
for the div 4 mode : baud = fosc/(4*(n+1))
with n being the divisor
```

We thus declare the multiple modes as div64, div16, div8 & div4.

# the tables

With the above formula, we calculate the baudrate divider. This value rounded to the nearest integer is taken into the reverse calculation to get the achieved baud rate. The Error then is
```Error = ((actual baudrate / declared baud rate)-1 )*100; // in percent
```
The table list the absolute error in the baudrate in percent. A "-" indicates the frequency cannot be achieved with sufficient accuracy.
 baud ratesquartz frequencies 300 600 1200 2400 4800 9600 19.2k 38.4k 57.6k 115.2k 250k 500k 1M 20MHz div8 - - 0 0 0.1 0.2 0.2 0.2 0.9 - 0 0 - 20MHz div16 - 0 0 0.1 0.1 0.2 0.2 1.7 - - 0 - - 18.432MHz div8 - 0 0 0 0 0 0 0 0 0 - - - 18.432MHz div16 0 0 0 0 0 0 0 0 0 0 - - - 16MHz div8 - 0 0 0 0.1 0.2 0.2 0.2 - - 0 0 0 16MHz div16 0 0 0 0.1 0.1 0.2 0.2 0.2 - - 0 0 0 14.7456MHz div8 - 0 0 0 0 0 0 0 0 0 - - - 14.7456MHz div16 0 0 0 0 0 0 0 0 0 0 - - - 11.0592MHz div8 - 0 0 0 0 0 0 0 0 0 - - - 11.0592MHz div16 0 0 0 0 0 0 0 0 0 0 - - - 8.0MHz div8 0 0 0 0.1 0.1 0.2 0.2 0.2 - - 0 0 0 8.0MHz div16 0 0 0.1 0.1 0.1 0.2 0.2 0.2 - - 0 0 - 7.3728MHz div8 0 0 0 0 0 0 0 0 0 0 - - - 7.3728MHz div16 0 0 0 0 0 0 0 0 0 0 - - - 6.0MHz div8 0 0 0 0.1 0.1 0.2 0.2 - 0.2 - 0 - - 6.0MHz div16 0 0 0.1 0.1 0.1 0.2 - - - - - - - 4.91MHz div8 0 0 0.1 0.3 0.7 1.5 - - - - - - - 4.91MHz div16 0 0 0.3 0.7 1.5 - - - - - - - - 4.19MHz div8 0 0 0.1 0.1 0.1 1.0 1.0 - 1.0 - - - - 4.19MHz div16 0 0 0.1 0.1 1 1.0 - - - - - - - 4.0MHz div8 0 0 0.1 0.1 0.1 0.2 0.2 0.2 - - 0 0 - 4.0MHz div16 0 0 0.1 0.1 0.1 0.2 0.2 - - - 0 - - 3.6864MHz div8 0 0 0 0 0 0 0 0 0 0 - - - 3.6864MHz div16 0 0 0 0 0 0 0 0 0 0 - - - 2.0MHz div8 0 0 0.1 0.1 0.1 0.2 0.2 - - - - - - 2.0MHz div16 0 0 0.1 0.1 0.1 0.2 - - - - - - - 1.8432MHz div8 0 0 0 0 0 0 0 0 0 0 - - - 1.8432MHz div16 0 0 0 0 0 0 0 0 0 0 - - - 1.0MHz div8 0 0 0.1 0.1 0.1 0.2 - - - - - - - 1.0MHz div16 0 0 0.1 0.1 0.1 - - - - - - - -

As can bee seen, the lower baud rates 300, 600 sometimes have problems when the 12 bit divider of an AVR overflows.
I wrote this software (500kB) which does just these calculations.

Questions ?
Suggestions?
Feedback ?