Dear Team.
I am having an issue to get the PIC32MX795F512L to run the correct speed and I try to explain the issue below
As a test I used MPLABX and Harmony to generate me the clock settings and it running fine on the mikroE EasyPIC Fusion Development board
XT = 8MHZ
Clock speed 80MHZ
the Harmony configuration
The same settings in the MikroE PIC32 Compiler Runs fine aswell
settings tested in 2 compilers and tool chains with no issue
Running the same settings in FC the clock speed is faster as it should be ,
I set a led on 10msec and off 10msec so an period of 20mSec effectivly as you will se below the ON and OFF timnes are 5mSec
totally incorrect
The configurations below
Notice the generated code the FPLLIDIV is set at 1 (I canot judge that this is correct or not) just showing what I see and the multipier is 5 which is x20
If I set the FPLLIDIV to x4 it causes the the timing to be 100% correct and the code generated show a value of 3 for FPLLIDIV
see below
in all cases the Peripheral clock is set at Pclk/1(div by 1 )
I attatch the project as well however in my humble opion there is an isse with the pic32 config settings in FC
The FC chart
I am in a serious problem as I need to do a CAN project for a customer and the timings are wrong so I will battle to get the CAN to work properly Thanks again for all the help and I would appreciate if we can point to the problem regardles me or FC
[attachment=0]
PIC32MX Clock setting issues
- p.erasmus
- Valued Contributor
- Posts: 434
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
PIC32MX Clock setting issues
- Attachments
-
- PLL_4_Config.jpg (55.12 KiB) Viewed 2913 times
Regards Peter - QME Electronics
- p.erasmus
- Valued Contributor
- Posts: 434
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
Re: PIC32MX Clock setting issues
Hi Team.
After a few more experiments
I set the FPLLIDIV to x2 as should be and configure Timer 2 Interrupt for 10mSec and then toggle led on RB1 and leaving the Toggle of LED on RB0 in the main loop controlled by the Delay component.
The interrupt fire exactly on the 10mSec and the delay timing is way off ,
This seems that the PIC32 is running at the correct clock speed as it si configured for however the delay calculations are wrong below a print of the timings and the code file.
CH1 delay timing control and CH2 is timer 2 interrupt controlled
Would you agree with me that it seems there is a problem with the delay component , please shed some light on this
After a few more experiments
I set the FPLLIDIV to x2 as should be and configure Timer 2 Interrupt for 10mSec and then toggle led on RB1 and leaving the Toggle of LED on RB0 in the main loop controlled by the Delay component.
The interrupt fire exactly on the 10mSec and the delay timing is way off ,
This seems that the PIC32 is running at the correct clock speed as it si configured for however the delay calculations are wrong below a print of the timings and the code file.
CH1 delay timing control and CH2 is timer 2 interrupt controlled
Would you agree with me that it seems there is a problem with the delay component , please shed some light on this
Regards Peter - QME Electronics
-
- Matrix Staff
- Posts: 1726
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 438 times
- Been thanked: 602 times
Re: PIC32MX Clock setting issues
Hello,
The FPLLIDIV set to /2 should be a value of 1 so that is correct.
The PIC32 devices have internal clock dividers and that is probably what's causing the timing issues.
What is your FPBDIV config setting set to?
The FPLLIDIV set to /2 should be a value of 1 so that is correct.
The PIC32 devices have internal clock dividers and that is probably what's causing the timing issues.
What is your FPBDIV config setting set to?
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
- p.erasmus
- Valued Contributor
- Posts: 434
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
Re: PIC32MX Clock setting issues
Hi Ben
In the config print above the internal devide is set to 0 (No divide ) FPBDIV = 0
How does that effect only the delay component (this is my issue ) the HW timing is correct as I have indicated by the TMR2 10mSec interrupt
I am confused
Thanks for your help
In the config print above the internal devide is set to 0 (No divide ) FPBDIV = 0
How does that effect only the delay component (this is my issue ) the HW timing is correct as I have indicated by the TMR2 10mSec interrupt
I am confused
Thanks for your help
Regards Peter - QME Electronics
-
- Matrix Staff
- Posts: 1726
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 438 times
- Been thanked: 602 times
Re: PIC32MX Clock setting issues
Hello,
Please can you try adding this to your supplementary code and see if that makes any difference.
Please can you try adding this to your supplementary code and see if that makes any difference.
Code: Select all
#define MX_CLKS_PER_INST 4
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
- p.erasmus
- Valued Contributor
- Posts: 434
- Joined: Thu Dec 03, 2020 12:01 pm
- Location: Russia / Россия
- Has thanked: 104 times
- Been thanked: 88 times
Re: PIC32MX Clock setting issues
Hi Ben
CLKS_PER_INST 4 has the same efect Delay component is to fast however
This solve the issue HW and Delay Component now has the same time value
What this define actually modify is not clear to me however for now it is OK but in future or if soemone change the Clock settings I suppose this will need a recalibrate also
CLKS_PER_INST 4 has the same efect Delay component is to fast however
Code: Select all
#define MX_CLKS_PER_INST 2
What this define actually modify is not clear to me however for now it is OK but in future or if soemone change the Clock settings I suppose this will need a recalibrate also
Regards Peter - QME Electronics
-
- Posts: 252
- Joined: Thu Dec 10, 2020 2:35 pm
- Has thanked: 36 times
- Been thanked: 17 times
Re: PIC32MX Clock setting issues
Hello
small error also with the PIC32MZ2048EFH100 200Mhz Flip Clickboard PIC32MZ
Loop with second cycle runs at second cycle
LED one sec on one sec off.
The second LED should do the same with a 10msec cycle in conjunction with a counter up to 100. But flashes faster
I have output the count value via a RS232 and it was the same, much too fast.
The build rate was correct.
With kind regards
SpeedPic32
small error also with the PIC32MZ2048EFH100 200Mhz Flip Clickboard PIC32MZ
Loop with second cycle runs at second cycle
LED one sec on one sec off.
The second LED should do the same with a 10msec cycle in conjunction with a counter up to 100. But flashes faster
I have output the count value via a RS232 and it was the same, much too fast.
The build rate was correct.
With kind regards
SpeedPic32
-
- Matrix Staff
- Posts: 1726
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 438 times
- Been thanked: 602 times
Re: PIC32MX Clock setting issues
PIC32 discussion continued here: viewtopic.php?p=5563#p5563
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