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.
dsPIC PLL clock confusion
Moderator: Benj
-
- 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
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).
(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.
Code: Select all
// Set clock to 80MHz mode
CLKDIV = 0b0000000000000010;
PLLFBD = 0x1E;
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
― C.S. Lewis