Pic32MZ2048EFG100 UART is 4 times to slow

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Pic32MZ2048EFG100 UART is 4 times to slow

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

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

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post by stefan.erni »

Hi Ben

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

regards

Stefan

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post 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 5228 times
http://ww1.microchip.com/downloads/en/D ... 01250B.pdf

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post 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 5209 times
http://wwww.matrixmultimedia.com/mmforu ... ilit=PIC32

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post 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 5070 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

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

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post 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 5023 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post 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);

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post 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
Attachments
PIC32MZ_TimingsChecking.fcfx
(10.33 KiB) Downloaded 175 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post 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 4983 times
Attachments
Baudrate.xlsx
(8.62 KiB) Downloaded 148 times

ronaldlijs
Posts: 139
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 20 times
Been thanked: 25 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Post 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 4436 times
Hope this helps, regards!
R

Post Reply