Hi all,
in fleurys uart lib, there is a makro to calculate the uart baudrate:
UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) (((xtalCpu)/((baudRate)*8l)-1)|0x8000)
Ok. The 0x8000 are for the doublespeed parameter and deleted in uart_init befor setting UBRR.
That makes this formula:
((xtalCpu)/((baudRate)*8l)-1)
Now let's calculate:
xtalCpu = 1Mhz = 1000000UL
baudrate = 19200
That results in:
= 1000000 / (19200*81) -1
= 1000000 / 1555200 -1
= 0.64 -1
= -0.64
or maybe because of unsigned it is:
= 1-1
= 0 which is written into UBRR
From specification The UBRR at 1MHZ and 19200baud should get a value of '6' at double speed.
What am I missing out here?