32MS250 Oscillator failure

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

Moderator: Benj

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

32MS250 Oscillator failure

Post by Pascal_2016 »

Hello

CPU 32MS250

My config settings are as follows:

#pragma config FNOSC = FRCPLL
#pragma config FPLLIDIV = DIV_2
#pragma config FPLLMUL = MUL_20
#pragma config FPLLODIV = DIV_2
#pragma config FPBDIV = DIV_1

#pragma config DEBUG = OFF // Background Debugger Enable: OFF

#define GetSystemClock() (40000000ul)
#define GetPeripheralClock() (GetSystemClock())

#include <plib.h>

The oscillator with 40 MHz should run according to the settings.

If I have a LED frequency of 1 Hz and select a clock speed from 40 MHz the LED speed is 0.5 Hz
If I have a LED frequency of 1 Hz and select a clock speed from 20 MHz the LED speed is 1.0 Hz
Which config settings are wrong.

Please Can You help me

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: 32MS250 Oscillator failure

Post by Benj »

Hello Pascal,
CPU 32MS250
Again, there is not a chip with this name. Can you please check your target type. Posting your Flowcode project file should help.

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Re: 32MS250 Oscillator failure

Post by Pascal_2016 »

The CPU is 32MX250

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: 32MS250 Oscillator failure

Post by Benj »

Hi Pascal,

There are a few chips that fit that description. However it sounds like if you change one of those divide by 2's to a divide by 1 then it should give you the 40MHz your looking for.

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Re: 32MS250 Oscillator failure

Post by Pascal_2016 »

Hi Benj
Unfortunately, the change does not lead to the desired success. The microcontroller not starting

Pascal_2016
Posts: 89
Joined: Wed Aug 31, 2016 4:48 pm
Been thanked: 4 times

Re: 32MS250 Oscillator failure

Post by Pascal_2016 »

Hi Benj,

With the configurations
#pragma config FNOSC = FRCPLL
#pragma config FPLLIDIV = DIV_2
#pragma config FPLLMUL = MUL_20
#pragma config FPLLODIV = DIV_2
#pragma config FPBDIV = DIV_1

#pragma config DEBUG = OFF // Background Debugger Enable: OFF

#pragma config OSCIOFNC = ON
#pragma config POSCMOD = OFF

#define GetSystemClock() (40000000ul)
#define GetPeripheralClock() (GetSystemClock())
.
With the configurations I see 40 MHz on the CLKO, no matter whether I select speed 20MhHz or 40 MHz in clock.

I think that the speed clock has been evaluated wrong.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hi Team

There is something wrong with the OSC settings in FC7 for PIC32MX2xxFxx devices ,
I also have a problem getting the correct OSC speed with a 4 MHZ XT the speed is 1/2 of what it should be :D
when I use the same settings in MPLAB the device runs exactly on 40MHZ as it should measuring a 10mSec delay in MPAB gives 10mSEC in FC the same 10mSEC yields 20mSec delay

Code: Select all

Settings 
FNOSC = XT_PLL           (4 MHZ Clock)
FPLLIDIV = DIV_1          (Input divider)
FPLLMUL = MUL_20      (multiplier)
FPLLODIV = DIV_2        (output divider)
FPBDIV = DIV_1            (peripheral clock divider)

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: 32MS250 Oscillator failure

Post by Benj »

Hi Peter,

Hmm could perhaps be a bug in the XC32 compiler inside Flowcode or in the Flowcode chip definition file. I'll check and see if there is a later version of the compiler and that the definition file settings make sense.

Can you check your Flowcode C code and see what numeric values are being passed. Sounds like one of these numbers may be wrong.

The definition file is looking ok for the 32MX250F128B device, the values and the datasheet seem to be matching up.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hi Ben

I will do this tonight when back at my lab

Regards

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hi Ben

Ok I checked the C code and looking in the Datasheet for the PIC32MX250F128B they seem to be correct,
The more I dig into this issue the more I get confused ,
measuring the On and off tome of a Pin it yields 20mSec and I would expect 10mSec if the device is running at 40Mhz ,I varified the imput clock frequency it gave me 250nSec which is 4Mhz
when i use the same setting and code in MPLAB I have the 10mSec On /off time .I attach the project may be you spot my mistake in the configuration.

:D
Attachments
2.JPG
2.JPG (36.32 KiB) Viewed 18971 times
1.JPG
1.JPG (27.38 KiB) Viewed 18971 times
PIC32MX250_BasicSetup.rar
(23.28 KiB) Downloaded 527 times
1.JPG
1.JPG (75.12 KiB) Viewed 18973 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: 32MS250 Oscillator failure

Post by Benj »

Sounds like a compiler bug or silicone workaround is happening. What version of the XC32 compiler are you using in MPLAB?

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hi Ben,

The XC32 V1.42 is the version I am using with in MPLAB and in FC it is the included version I am not sure what that version is :D
How can I add the path of the version 1.42(what should the syntax look like) to The compiler settings in FC I tried but not very successful by using the brows button in the compiler setting window
my path is as such programms (x86) \microchip\XC32 \1.42 \......
I would really like to compile the FC code in this version and then I will know for sure its a compiler bug or silicone work around as you mentioned and it will solve my issue

Thanks a million for your help

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: 32MS250 Oscillator failure

Post by Benj »

Hi Peter,

The compiler location will change from.
$(appdir)compilers\pic32\bin\xc32-gcc.exe
to this I think.
C:\Program Files (x86)\microchip\XC32\1.42\bin\xc32-gcc.exe
We are using version 1.40 in the current Flowcode release.

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: 32MS250 Oscillator failure

Post by Benj »

I was just looking at updating the XC32 compiler for the next release but then I found out that the size of the compiler has ballooned from 1.57GB to 3.02GB. Pretty much double the size.

So I will instead wait and see what your findings reveal before doing anything drastic.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hello Ben,
I have set the path as you mentioend and look like I am compiling with V1.42 now as attached
I am totally lost here the result is the same as with FC V1.40

You should not loose to much time with this as I am not sure if it is me causing the issue :shock: FC chart Below and CF config generated ,
Should I also change the path for the linker assembler as it seems to use the FC/Compiler/xc32 linker not the one with V1.42?


Happy times
Attachments
2.JPG
2.JPG (19.44 KiB) Viewed 18937 times
1.JPG
1.JPG (49.6 KiB) Viewed 18937 times
1.JPG
1.JPG (39.24 KiB) Viewed 18937 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hello Ben
I did now use in FC and in MPLAB the same amount of Nop instructions and in both cases the time measured were the same this is telling me that the controller is running at the correct frequency however in FC
when using the delay function or Interrupt calls where FC calculate some values from the set Frequency things go wrong this is my humble opinion and I has tried many things now which are pointing in this direction

I also setup a Timer 1 interrupt that should trigger every 20mSec 50Hz which does not work in FC (although when using the same amount of Nop's in FC) the speed measured is the same as in MPLAB with the same number of Nop()
Attachments
2.JPG
2.JPG (36.39 KiB) Viewed 18929 times
1.JPG
1.JPG (24.72 KiB) Viewed 18929 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: 32MS250 Oscillator failure

Post by Benj »

Ok so it could be an issue with the delays rather than the configuration settings.

I will investigate this a bit further thanks for letting us know.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Benj wrote: I will investigate this a bit further thanks for letting us know.
That would be great Ben thanks a million ,I am happy to inform you any issues I am having :D
As I mentioned I do not think it is only the delay that causes this it looks rather that the specified Clock frequency entered in FC in Configuration window is used by FC calculations of delays etc. and every where this number is used (also in the Interrupt calculations) things go wrong somewhere

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hello Ben,

Any update on this issue ,soon I will have to work on this project and was hoping that by that time we determined if it is me or FC that is the problem :D

I know you are very busy that also the reason I left it for more that 5 weeks before I tend to ask again :oops:
a small update would be great just to allow me to plan as well where to fit this project in as up to know I stil could not get FC code to run the correct Interrupt Timings or delays

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: 32MS250 Oscillator failure

Post by Benj »

Hi Peter,

Please could you attach your current project file and let me know what speed of crystal you're using (if you're using a crystal). Also if you create a 1s delay then how long does that delay actually last for?

There is a configuration setting that control the peripheral dividers. Maybe it is something to do with this?

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hi Ben

Attache the project I was using 5 weeks ago there might be some settings wrong in the config I am not sure as did many things at that time however
I am using an 4MHZ Crystal on the board and the timing for the delays are always double meaning 10mSec yield 20mSec and then for the interrupts I am setting the values in the parameters as you will see but they are way off in the code now it should interrupt at 20mSec but that does not happen I cant recall how much it were off when I last worked with the project as I am in Siberia and not close to the hardware to test it again.

this is the fuse settings I used in MPLAB and then it runs fine as you will notice from our discussion above and even using the FC generated fuse setting in MPLAB Runs fine and also when I use only NOP instructions in FC and in MPLAB the timings are the same its only when I use blocks in FC that calculates some values from the given Clock frequency set in FC then things go wrong

Hope you can see what I am doing wrong Thanks a million :D
Settings
FNOSC = XT_PLL (4 MHZ Clock)
FPLLIDIV = DIV_1 (Input divider)
FPLLMUL = MUL_20 (multiplier)
FPLLODIV = DIV_2 (output divider)
FPBDIV = DIV_1 (peripheral clock divider)
Attachments
PIC32MX250_BasicSetup.zip
(29.02 KiB) Downloaded 324 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: 32MS250 Oscillator failure

Post by Benj »

Hi Peter,

Ok your input clock is 4MHz from a crystal.

PLLIDIV = 1
PLLMUL = 20x Multiply
PLLODIV = 2x Divide

Based on these settings your Project options clock speed should be 40,000,000 which is what you have now.

((4MHz / 1) x 20) / 2

However it looks from the block diagram that the /2 is not used by the Reference clock. I wonder if you change the /2 to /1 and set the project clock speed to 80000000 then maybe things would work as expected? I'm not yet an expert on PIC32 so maybe I need to have more of a play to see what impact the various settings have.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Ben

I have tried that setting to /1 in FC and in MPLAB in the past and in both cases you have zero output then as if there is no clock the IO pins would not respond at all as if the mcu is not running,
do not spend to much time on this now, I will only be back at my lab in December where I have hardware to test your ideas now I am far from my lab :D

Edit What I did not do was changing the clock setting inn FC to 80 000000 will try that when in my lab good catch Ben

Let us take this on together when I am back, I am sure we will find the solution, I know the MX 4/6/7 family well however never worked with the 250,and smaller ones which runs max 48MHZ

once again thanks a million

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: 32MS250 Oscillator failure

Post by QMESAR »

Hi Ben

After 2 months away from my lab I am finally back and had a go at this again :D
Ok your input clock is 4MHz from a crystal.

PLLIDIV = 1
PLLMUL = 20x Multiply
PLLODIV = 2x Divide

Based on these settings your Project options clock speed should be 40,000,000 which is what you have now.

((4MHz / 1) x 20) / 2

However it looks from the block diagram that the /2 is not used by the Reference clock. I wonder if you change the /2 to /1 and set the project clock speed to 80000000 then maybe things would work as expected? I'm not yet an expert on PIC32 so maybe I need to have more of a play to see what impact the various settings have.
This I tried however FC does not allow me to put in a value of higher than 50 Mhz for this device

I have then tied various setting for the Input and out put dividers and also for the multiplier with no luck the speed is always half of what it should be ,
I then made a Timer 2 interrupt with pre-scaler of 8 at 40 Mhz the interrupt frequency should be 38.147 Hz the interrupt fire at 49.2 Hz

I am sorry about this however the timing just does not fit to it's set parameters why I have no idea ,do you have such an device if so please can you try to see if you get it to run at the correct speed
I am not sure any more may be I am just plain stupid
Attachments
3.JPG
3.JPG (18 KiB) Viewed 15981 times
1.JPG
1.JPG (30.97 KiB) Viewed 15981 times
2.JPG
2.JPG (27.49 KiB) Viewed 15981 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: 32MS250 Oscillator failure

Post by Benj »

Hi Peter,
I am sorry about this however the timing just does not fit to it's set parameters why I have no idea ,do you have such an device if so please can you try to see if you get it to run at the correct speed
I am not sure any more may be I am just plain stupid
I'm sure that's not the case. Some of these new PICs have some very fancy features which make working them out very difficult. I'll see if I can investigate for you and work out just what's going on.

Post Reply