Pic32MZ2048EFG100 UART is 4 times to slow

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

Moderator: Benj

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 166 times
Been thanked: 153 times
Contact:

Pic32MZ2048EFG100 UART is 4 times to slow

Postby stefan.erni » Thu Jun 27, 2019 6:11 pm

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
Config_clock.PNG (98.59 KiB) Viewed 1128 times

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

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby Benj » Mon Jul 01, 2019 9:54 am

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
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 166 times
Been thanked: 153 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby stefan.erni » Mon Jul 01, 2019 9:57 am

Hi Ben

Here the program

Fc8_efg100_emg_ekg_prototype_v15.fcfx
(448.42 KiB) Downloaded 39 times



regards

Stefan

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 166 times
Been thanked: 153 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby stefan.erni » Tue Jul 02, 2019 3:47 pm

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.9 KiB) Viewed 1060 times


http://ww1.microchip.com/downloads/en/D ... 01250B.pdf

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 166 times
Been thanked: 153 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby stefan.erni » Wed Jul 03, 2019 10:38 am

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.58 KiB) Viewed 1041 times


viewtopic.php?f=78&t=20139&hilit=PIC32

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 166 times
Been thanked: 153 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby stefan.erni » Mon Aug 05, 2019 10:46 am

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 902 times

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

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby Benj » Mon Aug 05, 2019 4:33 pm

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
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 166 times
Been thanked: 153 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby stefan.erni » Tue Aug 06, 2019 11:01 am

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 855 times

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 166 times
Been thanked: 153 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby stefan.erni » Tue Aug 06, 2019 3:45 pm

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);
These users thanked the author stefan.erni for the post:
Lagoda (Tue Aug 06, 2019 9:52 pm)
Rating: 5.26%
 

Lagoda
Posts: 149
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 63 times
Been thanked: 59 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby Lagoda » Tue Aug 06, 2019 10:19 pm

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 21 times
These users thanked the author Lagoda for the post:
stefan.erni (Wed Aug 07, 2019 1:00 pm)
Rating: 5.26%
 

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 166 times
Been thanked: 153 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby stefan.erni » Wed Aug 07, 2019 1:00 pm

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 815 times
Attachments
Baudrate.xlsx
(8.62 KiB) Downloaded 17 times

ronaldlijs
Posts: 98
Joined: Tue Jan 05, 2010 10:07 am
Has thanked: 9 times
Been thanked: 21 times
Contact:

Re: Pic32MZ2048EFG100 UART is 4 times to slow

Postby ronaldlijs » Sat Nov 16, 2019 11:28 am

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 268 times


Hope this helps, regards!
R
These users thanked the author ronaldlijs for the post:
QMESAR (Sat Nov 16, 2019 2:00 pm)
Rating: 5.26%