dsPIC PLL clock confusion

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
clee
Flowcode v5 User
Posts: 15
Joined: Fri Dec 09, 2011 4:23 am
Has thanked: 3 times
Been thanked: 3 times

dsPIC PLL clock confusion

Post by clee »

I'm using a 33FJ128GP802 dsPIC chip with a 20MHZ crystal. I have the OSCILLATOR MODE set to Primary OSC w/PLL. My OSCILLATOR MODE is set to HS Oscillator.

In the program I have an interrupt set:

TMR1
Clock: Internal (Fosc/2)
Prescale: 1:1
Rollover: 512

Giving the parameters,
Clock Speed 20000000 HZ
Interrupt Frequency 19531.250 HZ

When I check a pin that toggles with the interrupt on a scope I get a period of 15us for each interrupt call. That works out to about 66.6kHZ

How is Flowcode setting the PLL. There are several dividers and multipliers that need to be set but I don't see anywhere to set those or see how they are set. It's good that the Interrupt is running that fast, but I'd like to know why.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: dsPIC PLL clock confusion

Post by kersing »

You need to include a C code block to set the additional registers yourself if you want to us PLL. I'm using the code below to set a 33fj128gp708 to 80MHz (xtal is 20MHz).

Code: Select all

// Set clock to 80MHz mode
CLKDIV = 0b0000000000000010;
PLLFBD = 0x1E;
(Make sure to observe the limits specified in the data sheet for your controller. PLL clock stages should not exceed certain limits)

If you do not require the PLL to multiply your frequency, set the oscillator mode to Primary Oscillator (no mention of PLL). That should result in 20MHz clock.

If you do not add any settings Flowcode will not set anything by itself, so the defaults listed in the data sheet will be active.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

clee
Flowcode v5 User
Posts: 15
Joined: Fri Dec 09, 2011 4:23 am
Has thanked: 3 times
Been thanked: 3 times

Re: dsPIC PLL clock confusion

Post by clee »

Thanks,

Worked like a charm.

Craig

Post Reply