Page 1 of 1

PLL Enabling Problem in 18f14k22

Posted: Thu Dec 01, 2016 7:53 pm
by sysprofessional
Hi,

I am using PIC18f14K22 in my project.I want to use 16MHz internal Oscilator with PLL enable.
But OSCTUNE.PLLEN bit did not working.
I have write C code at the beginning in flowchart with these parameters, osccon = 0b01110110; osctune = 0b01011111;
and flash a led with 500ms delay in flowchart.and got 4 test using oscilloscope.
1st test with osctune = 0b01011111; //enable pllen bit
2nd test with osctune = 0b00011111; // disable pllen bit
3rd test with //osctune = 0b01011111;
4th test using timer0 at 1:128 prescaler (122.07Hz),using one counting variable,if variable >=61 , led on, otherwise off, if Variable=122,reset to zero.

Every test shown 1Hz frequency on scope.
I have also define frequecy in C code at the top # define _xtal_freq=16000000;
but same result at all.

Note: There is no external crystal attached in my circuit.

OSCCON , OSCTUNE register in datasheet and Config option shown below.

Best Reagrds
Sysprofessional

Re: PLL Enabling Problem in 18f14k22

Posted: Thu Dec 01, 2016 9:37 pm
by medelec35
Hi Sysprofessional,
It would help us if you posted your flwochart as could have made a mistake within configuation settings.
Assuming you wish to run internal osc at 64MHz:
What you will need to do is either place at the very start on main a C code block with

Code: Select all

osccon=0x70; 
and enable PLL within config settings.
Since

Code: Select all

osccon=0x70; 
and pll enabed just sets internal osc to 16MHz x 4
You must also set the clock speed to 64MHz.

What you could also do if you have a scope is enable clockout and check the freqency is = 64MHz/4 = 16MHz

If still struggling i will help you to look further into this.


Martin