BRG number for the PIC32MZ

For general Flowcode discussion that does not belong in the other sections.
Post Reply
SpeedPIC32
Posts: 278
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 2:35 pm
Location: Germany
Has thanked: 37 times
Been thanked: 17 times

BRG number for the PIC32MZ

Post 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

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

Re: BRG number for the PIC32MZ

Post 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.

SpeedPIC32
Posts: 278
Joined: Thu Dec 10, 2020 2:35 pm
Location: Germany
Has thanked: 37 times
Been thanked: 17 times

Re: BRG number for the PIC32MZ

Post by SpeedPIC32 »

Hi Ben, I have something to try.

Please test it and publish it if it is ok.
Attachments
compilation_brg.zip
(3.44 MiB) Downloaded 230 times

Post Reply