Page 1 of 1
changing internal clock speed
Posted: Sat Dec 31, 2011 12:09 pm
by geetansh
hello
i have a little problem, i m using PIC18F4685 n i m using its internal oscillator.
everything is working fine but the internal oscillator is running at 1Mhz(default) but i want 8 or 4Mhz so please tell me how i can change internal oscillators frequency.
thank you.
Re: changing internal clock speed
Posted: Sat Dec 31, 2011 6:22 pm
by medelec35
Higeetansh,
At the very beginning of the flowchart (Main Macro) Place a C code box with
That should run internal osc at 8MHz
If use
instead,
then internal osc should run at 4MHz
If you look at the data sheet, then you can determine what values should be.
This is for a different target device, but take a look here:
http://www.matrixmultimedia.com/mmforum ... 29&#p28829
Martin
Re: changing internal clock speed
Posted: Mon Jan 02, 2012 7:17 am
by geetansh
thanks martin!
Re: changing internal clock speed
Posted: Mon Jan 02, 2012 9:11 am
by geetansh
hey 8Mhz is working fine but i think now i need freq around 20Mhz. (without using external oscillator)
i saw the link given n using PLL 16MHz and 32MHz freq can be achieved but i m going wrong somewhere
these are my steps (i am using PIC18F4685 without any external oscillator)
1. i selected this in the expert config. screen oscillator - HS-PLL enabled=4xFosc1
2. c code inserted was osccon=0xF0;
but when i checked it on hardware it was still running at 8Mhz.
so can you please tell me where i m wrong and the correct steps to get 16Mhz or 32Mhz freq without using any external oscillator?
Re: changing internal clock speed
Posted: Mon Jan 02, 2012 1:22 pm
by medelec35
Hi geetansh,
Since PLL multiplies internal osc by 4, what you have stated is correct.
Only speeds you can achieve with PLL enabled is 4 x 4 = 16MHz
& 8 X 4 =32MHz
Here are the steps I would take for setting internal osc to 16MHz
1)Target clock speed to 16MHz, (I would 1st select 10 or 12MHz and just change second digit to a 6
2) Since 16MHz is 4 X 4 you will need to set internal oscillator to 4MHz.so use a C Code box with
osccon=0x60;
at the start of Main macro.
3) In expert Configuration, Set Oscillator to HS-PLL enabled freq=4xFosc1,
Change Watchdog Timer, Low Voltage Program
& Extended CPU Enable from Enabled to disabled.
Give that a go, and if still not working then If you post your flowchart (assuming it's not commercially sensitive) , someone will take a look at it for you.
Martin
Re: changing internal clock speed
Posted: Mon Jan 02, 2012 2:40 pm
by cobra1
Hi, the HS-PLL wont work with the internal clock, well at least i couldnt get it to work.
It needs to have an external clock to work with the HS-PLL,
Put an 8mhz crystal in the hardware and set HS-PLL and you will get 32mhz clock speed
Re: changing internal clock speed
Posted: Mon Jan 02, 2012 3:08 pm
by medelec35
Hi cobra1,
Sorry to hear you could not get PLL to work with internal osc.
These chips are designed to work at 16 and 32 MHz in conjunction with internal oscillator as well as external osc.
here is the block diagram:
As you can see the connection from internal osc and PLL block
cobra1 wrote:Hi, the HS-PLL wont work with the internal clock, well at least i couldnt get it to work.
You are correct! Looking at the data sheet I have made a mistake saying about HS-PLL enabled freq=4xFosc1
Sorry about that.
To enable PLL to work with internal osc try this.
Add to C code block you have got at the beginning:
So you should have:
Then In expert Configuration, Set Oscillator to 1 of the INT configurations
Thanks cobra1 for mentions you could not get it to work, thats what made me look at the datasheet in more detail.
Martin
Re: changing internal clock speed
Posted: Mon Jan 02, 2012 3:41 pm
by cobra1
No problem, i myself have learnt something new

Re: changing internal clock speed
Posted: Wed Jan 04, 2012 8:03 am
by geetansh
hello guys i tried it on hardware(without osctune) n it didnt worked then i looked at datasheet n found out osctune<6> needs to be set.
i was just posting my doubt about it but u guys have already solved it.
thanks to u both.

Re: changing internal clock speed
Posted: Wed Jan 04, 2012 8:18 am
by geetansh
what's the use of "Extended cpu enable" ????
so that i knw the difference on hardware response when it is enabled or disabled.
Re: changing internal clock speed
Posted: Wed Jan 04, 2012 8:32 am
by medelec35
Hi geetansh,
Glad PLL is now working with internal osc.
One issue I know of with Extended cpu is it appears to cause problems with string arrays.
So if enabled will stop LCD from working correctly.
Re: changing internal clock speed
Posted: Wed Jan 04, 2012 8:37 am
by geetansh
any link or doc to know more about it??
Re: changing internal clock speed
Posted: Wed Jan 04, 2012 11:08 am
by cobra1
I had mega problems with the extended CPU. Took me over a week to find it was actually that causing the problem. I don't know what it does exactly. But I just disable it. I disable everything that I don't fully understand.