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
BRG number for the PIC32MZ
-
SpeedPIC32
- Posts: 300
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 10, 2020 2:35 pm
- Location: Germany
- Has thanked: 41 times
- Been thanked: 18 times
-
BenR
- Matrix Staff
- Posts: 1989
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 523 times
- Been thanked: 710 times
Re: BRG number for the PIC32MZ
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
SpeedPIC32
- Posts: 300
- Joined: Thu Dec 10, 2020 2:35 pm
- Location: Germany
- Has thanked: 41 times
- Been thanked: 18 times
Re: BRG number for the PIC32MZ
Hi Ben, I have something to try.
Please test it and publish it if it is ok.
Please test it and publish it if it is ok.
- Attachments
-
- compilation_brg.zip
- (3.44 MiB) Downloaded 241 times