Page 1 of 1

Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Thu Jun 27, 2019 6:11 pm
by stefan.erni
Hi Ben

Have a problem with the Pic32MZ2048EFG100 and the UART.
The speed from the hardware UART is about 4 times to slow. The clock is ok with 200Mhz because the delay from 1mSec is perfect.
How can I acces the PB2DIV from the PIC?

regards

Stefan
Config_clock.PNG
(98.59 KiB) Downloaded 1825 times

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Mon Jul 01, 2019 9:54 am
by Benj
Hello,

On the PIC32 devices there is a peripheral clock as well as the main oscillator clock. Can you post your program so we can see what the various configuration settings are set to.

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Mon Jul 01, 2019 9:57 am
by stefan.erni
Hi Ben

Here the program
Fc8_efg100_emg_ekg_prototype_v15.fcfx
(448.3 KiB) Downloaded 208 times

regards

Stefan

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Tue Jul 02, 2019 3:47 pm
by stefan.erni
Hi Ben

I found some infos about it.
And I tried it.

But the Baudrate (speed) did not change.But I dont have a error. Maybe I did something forget?

Code: Select all

/*
  Enter C code below this comment
*/
//Unlock Combination
_SFR_WRITE(&SYSKEY, 0xAA996655);
_SFR_WRITE(&SYSKEY, 0x556699AA);

//Unlock
_SFR_BIT_SET(&PB3DIV, 11);

//_SFR_BIT_SET(&PB3DIV, 1);
_SFR_BIT_CLEAR(&PB3DIV, 1);
// now lock again PB3DIC
_SFR_BIT_CLEAR(&PB3DIV, 11);
// now lock again


_SFR_WRITE(&SYSKEY, 0x0);
Clock_DIV.JPG
Clock_DIV.JPG (107.89 KiB) Viewed 5338 times
http://ww1.microchip.com/downloads/en/D ... 01250B.pdf

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Wed Jul 03, 2019 10:38 am
by stefan.erni
Hi Ben

In a old post I found about the divider on an another PIC32(MX).
This I FPBDIV I cannot find for the PIC32MZ2048EFG100
Also a little special…. The Baudrate on the ECG PIC was ok..

Uart_PIC32MZ.JPG
Uart_PIC32MZ.JPG (56.57 KiB) Viewed 5319 times
http://wwww.matrixmultimedia.com/mmforu ... ilit=PIC32

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Mon Aug 05, 2019 10:46 am
by stefan.erni
Hi Ben

There is a little problem to fix the speed from the Uart and SPI.
I suspect that this setting is missing for the clock in FC8 and PIC32MZ2048EFG100.

When I try to change this while the PIC is running,
the PIC need 60 steps to change it. How can I program it?

Stefan
Clock_PIC_.JPG
Clock_PIC_.JPG (85.49 KiB) Viewed 5180 times

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Mon Aug 05, 2019 4:33 pm
by Benj
Hi Stefan,

You should be able to use a delay icon to do the task of waiting at least 60 CPU clocks. I would guess that say a 1ms delay would be plenty.

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Tue Aug 06, 2019 11:01 am
by stefan.erni
Hi Ben

I like to show first the value from the register on the display of the board.
As if its working not correct.
So I tried to test with the watchdog settings
It shows me values, but if I show DEVCFG1 and change the value from the watchdog WDTPS in the project-option-config.
it shows me always the same value…..
But the value in the C-code changed

Code: Select all

#pragma config WDTPS = 14 to ]#pragma config WDTPS = 6 

Code: Select all

//show  register on display

//_SFR_BIT_SET(&PB3DIV, 4);
FCI_DELAYBYTE_MS(1);

//FCV_REGDISPLAY  = &PB3DIV;	      //Copy to variable

//FCV_REGDISPLAY  = &DEVCFG2;
FCV_REGDISPLAY  = &DEVCFG1;

FCD_08221_LCD_SSD1351__ClearDisplay();
FCD_08221_LCD_SSD1351__PrintNumber(FCV_REGDISPLAY, 50, 50, 0, 0);
WDTPS.JPG
WDTPS.JPG (55.75 KiB) Viewed 5133 times

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Tue Aug 06, 2019 3:45 pm
by stefan.erni
Hi Ben

To set the clock divider is working but it's not the problem.

I think it's more on the UART config. It looks like the BRGH is wrong (I or 0) I will check it tomorrow….

here the code to set PB2DIV

Code: Select all

//Unlock Combination
_SFR_WRITE(&SYSKEY, 0xAA996655);
_SFR_WRITE(&SYSKEY, 0x556699AA);

//_SFR_BIT_SET(&PB2DIV, 1);
//_SFR_BIT_SET(&PB2DIV, 4);

FCV_REGDISPLAY  = PB2DIV;
// now lock again
_SFR_WRITE(&SYSKEY, 0x0);
FCD_08221_LCD_SSD1351__ClearDisplay();
FCD_08221_LCD_SSD1351__PrintNumber(FCV_REGDISPLAY, 50, 50, 0, 0);

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Tue Aug 06, 2019 10:19 pm
by Lagoda
Hi Stefan and Ben,

I have the same problem with the PIC32MZ EFM.
My target board is Microchip Curiosity.
I attached a little test program what I used for the check.

Best Regards,

Lagoda

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Wed Aug 07, 2019 1:00 pm
by stefan.erni
Hi Lagoda, Hi Ben

The BRGH bit is correct. It's 1. But the value for the Baudrate-generator BRG is (maybe) wrong
I attached an excel table with the old and new value. I take a measurement with my Osciloscope and it's shows 8.69 uSec for one bit. And the terminalprogram is working with 115200 Bd.

Code: Select all

// For uart Nr 4  115200 Baud C Code
U4BRG=216;
BRG.JPG
BRG.JPG (53.15 KiB) Viewed 5093 times

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Posted: Sat Nov 16, 2019 11:28 am
by ronaldlijs
Hi Ben et al,

Just to say that I obviously have run into this problem as well. We have not tried Software UART option (in case this works for some reason) as we need the RXINT though.

Our MCU FYI is PIC32MZ1024EFE100

The only solution at the moment is to modify the Flowcode settings to match the real life. Simply multiply by 4x the baud rate used, set the Baud Options to Custom and enter the new number into the Baud Rate field for the UART Component in Flowcode 8.

SO TO MAKE IT CLEAR FOR OTHER PEOPLE RUNNING INTO THIS PROBLEM...

Say you use baud rate 57600 (our case). Simply multiply this number by 4x which equals 230400. And enter this new number in the Flowcode properties window as below. The clocked UART output stream runs exactly at 57600bps :D
FC_RS232.jpg
FC_RS232.jpg (36.89 KiB) Viewed 4546 times
Hope this helps, regards!
R