Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How do I get 64MHz on 18F25k22

Pommie

Well-Known Member
Most Helpful Member
Hi all,
Back again.
My project needs to go faster so I opted to switch from 16MHz to 64MHz.
The datasheet states,
1717880904859.png

No problem, just need to enable the PLL and 64MHz it is.
Didn't work. So, used the code configurator to get the right values,
1717881012668.png

Note: I've tried both the PLL boxes with the same result.
The generated code states a clock of 16MHz!!!
1717881128941.png

and if you run an LED flash type program it is indeed running at 16MHz.
To test this I setup a new project called test_oscillator and used the code configurator as above.
However, when trying to debug it tells me,
1717881293555.png

Yes, I know I spelt oscillator wrong.
What does this mean?
Anyone know IF I can run this chip at 64MHz or not?

Thanks,

Mike.
 
Yes, it'll run at 64MHz. I don't use MCC, so I don’t know what boxes to check, but it involves setting the OSCCON register in code to set the intosc to 16M and enabling the 4x PLL
 
The code I have at the moment does exactly that and runs at 16MHz.
I.E.
Code:
    OSCCON=0b01110000;      //16MHz please
    //can now select PLL and increase to 64MHz
    PLLEN=1;                //switch to 64MHz
That is why I tried the MCC to see how it setup the registers but it does the same and it runs at 16MHz.

Mike.
 
Pommie, I just use the MCC to find the correct settings (there's so many config settings I always do that :D), I then simply cut and paste the part I want from it.

In your OP the screenshot clearly shows the oscillator set to 16MHz_HFINTOSC, and says above "Current system clock 16MHz", I've just tried running the MCC on that chip, and if you select INTOSC it gives a warning that PLL is not applicable.

MCC1.png


If you choose the 18F27K42 (my 'goto' 18F chip) it easily lets you select the 64MHz option:

MCC2.png


From that I would assume the 18F25K22 doesn't allow the PLL with the internal oscillator?, and the MicroChip web page suggests using it's newer version the 18F25Q10 - which says 64MHz internal oscillator in the product features, the 18F25K22 doesn't.

It just says "Software selectable frequencies range of 31 kHz to 16 MHz" and "Four Crystal modes up to 64 MHz".
 
To get the 2xK22 to run at 64MHz using the intosc you need to do two things:

- set CONFIG1H to either
Code:
config FOSC = INTIO67           // Internal oscillator block
or 
config FOSC = INTIO7            // Internal oscillator block, CLKOUT function on OSC2
FOSC<3:0> must be 1000 or 1001

Then in your code set
Code:
OSCCON = 0b01110000    // HFINTOSC (16 MHz), SCS=00 Primary clock (determined by FOSC<3:0>)
OSCTUNE.bits(PLLEN) = 1     // enable 4xPLL

The syntax for setting the OSCTUNE PLLEN register bit depends on your language.
The chip will run at 1MHz until you execute those two lines, so you'll want to do it as soon as possible at startup.
 
Last edited:
Seems the problem was I set the lower two bits of OSCCON to zero as I wanted to use the internal oscillator - they need to be 11. Edit, I'm sure I tried this before without success as shown in post #3.
Oh well, problem solved - onward and upward.

Mike.
BTW, Nigel, my code configurator states that 16MHz can use the PLL!!!!
I don't understand where you're selecting the HFINTOSC.
1717963313771.png
 
Last edited:
Seems the problem was I set the lower two bits of OSCCON to zero as I wanted to use the internal oscillator - they need to be 11.
Are you sure you have that around the right way?
If you set the lower two bits of OSCCON to 1x then the PLL gets bypassed. The clock mux (System Clock Select) needs to select the Primary Clock to use the PLL. See datasheet FIGURE 2-1

The code I posted in #6 works.
 
Seems the problem was I set the lower two bits of OSCCON to zero as I wanted to use the internal oscillator - they need to be 11. Edit, I'm sure I tried this before without success as shown in post #3.
Oh well, problem solved - onward and upward.

Mike.
BTW, Nigel, my code configurator states that 16MHz can use the PLL!!!!
I don't understand where you're selecting the HFINTOSC.
View attachment 146139
What does it say under the 'Notifications(MCC)' tab?, that's where it said it wasn't available. The datasheet is incredibly vague about it.
 
The datasheet is incredibly vague about it.

The datasheet seams to be very specific (and clear) about it,
1718012882566.png

It states very clearly that it can run at 64Mhz using the internal clock with the PLL.

However, as stated earlier, problem solved, onward and upward.

Mike.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top