News:

Let's find out together what makes a PIC Tick!

Main Menu

PLL_Setup query

Started by RGV250, Jul 14, 2026, 05:47 PM

Previous topic - Next topic

RGV250

Hi,
I have been looking for information regards the PLL setup and the closest information I can find is this from the oscillator frequency declare in the manual.
I am trying to figure out what these figures actually equate to in the device datasheet and what the $0300 is for.
Also, if I wanted to tweak it with OSCTUN I assume that I would need to do that prior to PLL_Setup but cannot find that either.

QuoteExample 3
' PIC24H internal 7.37MHz oscillator operating at 79.23MHz using PLL
'
Device = 24HJ128GP502
Declare Xtal = 79.23
'-------------------------------------------------------------------
Main:
' Configure the Oscillator to operate the device at 79.23MHz
' Fosc = (7.37 * 43) / (2 * 2) = 79.23MHz (40 MIPS)
'
PLL_Setup(43, 2, 2, $0300)

Regards,
Bob

trastikata

Here's an example how I set up dsPIC33EP512MC806 using an Excel spreadsheet I've created.

The clock calculation formula has one small difference that adds few clocks, but you will have an idea how to setup the 24HJ128GP502 (it does not have the PLLDIV + 2).

dsPIC_CLOCK.zip

And here's the Positron code:

'Set Fosc   
Proc SetCrystal()
    Clear
    'FRC = 8 MHz --> PLLDIV = 68 for 140MHz / PLLDIV = 73 For 150MHz
    CLKDIV = %0000000000000000 'PLLPRE = 0 ; PLLPOST = 0
    PLLFBD.Byte0 = 73 '--> 150MHz Fp
    OSCCON = %0000000100000000
    OSCTUN = 23
    'Wait for oscillator PLL lock
    While OSCCON.5 = 0 : Wend
EndProc 

Clock.jpg

RGV250

Hi,
I changed cell B1 to =B3*((B4)/((B5)*(B6)))  and this seems to be good for my PIC24 device.

Bob

trastikata

#3
Hi Bob,

indeed the formulae for miscellaneous devices have some differences, but the principle is the same:

- Fin / PLLPRE = Fref - the clock source is divided by the prescaller (with some additional integer value if required by the datasheet)
- 0.8 MHz < Fref < 8.0 MHz most of the time the clock source to the PLL should be 0.8 to 8 MHz
- Fref * PLLDIV = Fvco - Multiply that by the feedback (with some additional integer value if required by the datasheet)
- xxx MHZ < Fvco < xxx MHZ - The output of the Fvco should be within the range indicated in the datasheet
- Fvco / PLLPOST = Fosc - Divide that Fvco by the postscaller (with some additional integer value if required by the datasheet)

One thing to watch - VCO range as indicated.
Fosc.png