changing internal clock speed
changing internal clock speed
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.
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.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: changing internal clock speed
Higeetansh,
At the very beginning of the flowchart (Main Macro) Place a C code box with That should run internal osc at 8MHz
If useinstead,
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
At the very beginning of the flowchart (Main Macro) Place a C code box with
Code: Select all
osccon=0x70;
If use
Code: Select all
osccon=0x60;
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
Martin
Re: changing internal clock speed
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?
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?
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: changing internal clock speed
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
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
Martin
Re: changing internal clock speed
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: changing internal clock speed
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
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
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
You are correct! Looking at the data sheet I have made a mistake saying about HS-PLL enabled freq=4xFosc1cobra1 wrote:Hi, the HS-PLL wont work with the internal clock, well at least i couldnt get it to work.
Sorry about that.
To enable PLL to work with internal osc try this.
Add to C code block you have got at the beginning:
Code: Select all
osctune.PLLEN=1;
Code: Select all
osccon=0x60;
osctune.PLLEN=1;
Thanks cobra1 for mentions you could not get it to work, thats what made me look at the datasheet in more detail.
Martin
Martin
Re: changing internal clock speed
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.
i was just posting my doubt about it but u guys have already solved it.
thanks to u both.

-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: changing internal clock speed
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.
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.
Martin
Re: changing internal clock speed
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.