Page 1 of 1

BRG number for the PIC32MZ

Posted: Wed Jun 02, 2021 10:10 pm
by SpeedPIC32
Who can tell me the formula for the calculation?
I will write a small software for it.
I will publish the software here.
Thanks already

Re: BRG number for the PIC32MZ

Posted: Thu Jun 03, 2021 12:35 pm
by BenR
Hello,

We currently calculate the baud like this.

SlowMode = 0
BRGVAL = ((CLOCKSPEED / BAUD) / UART_INST_PER_CLK)

if (BRGVAL > 65535)
{
SlowMode = 1
BRGVAL = ((CLOCKSPEED / BAUD) / (UART_INST_PER_CLK * 4))
}

UART_INST_PER_CLK is typically 4 for the MX devices and 2 for the MZ devices at the very fastest but this seems to vary between devices and can be increased via a configuration setting.

Re: BRG number for the PIC32MZ

Posted: Thu Jun 03, 2021 6:58 pm
by SpeedPIC32
Hi Ben, I have something to try.

Please test it and publish it if it is ok.