PIC UART baud rate calculator
Another quick post. I needed to calculate the UART baud rate generator register value for different rates and the error I was having because the internal clock I was using, 32 MHz, does not neatly divide into any of the more standard values so I fired up a LibreOffice spreadsheet and made it show me what configuration matches the desired baud rate the best, the error, and it also neatly paints the error values in red / yellow / green colours depending on whether the error percent is above 1%, below 1%, or exactly 0% so for my 32 MHz clock it shows:
Download the LibreOffice Calc document here.
Only some not really standard but widely supported baud rates like 250000 and 500000 bps match exactly, although many standard rates have error margins well below 1% but if I had chosen a proper UART clock like 12.9024 MHz the table would look greener:
And also some “can’t do” baud rates where the “correct” register value would be negative 😉