ds30 Loader free edition forums
UARTBR - wrong baud rate calculation formula [solved] - Printable Version

+- ds30 Loader free edition forums (https://picbootloader.com/forum)
+-- Forum: Support (https://picbootloader.com/forum/forumdisplay.php?fid=3)
+--- Forum: 16-bit firmwares (https://picbootloader.com/forum/forumdisplay.php?fid=6)
+--- Thread: UARTBR - wrong baud rate calculation formula [solved] (/showthread.php?tid=78)



UARTBR - wrong baud rate calculation formula [solved] - yuters - 2011-04-24

Hi,
As I see in PIC24FJ128GA110 datasheet (page 182) the UART baud rate with "BRGH = 1" calculated by following formula:
UARTBR = (FCY/(4*Baud Rate) -1)

but in BL code I see following:
.ifdef USE_BRGH
.equ UARTBR, ( (((FCY / BAUDRATE) / 2) - 1) / 2 )
.endif

The datasheet formula checked in my applications and work fine on 115200 bps baud rate.

So it's looking like there must be:
.equ UARTBR, ((FCY / (4*BAUDRATE)) - 1)

Is it try?
Regards.
Yuters


RE: UARTBR - wrong baud rate calculation formula - Mikael Gustavsson - 2011-04-24

Hi,
My version does rounding to achieve better results.
Try it yourself to see how it works.

Thanks,
Mikael