Increase my frequency of Oscillation from 8 to 32 MHZ

Status
Not open for further replies.

Neyolight

Full Member level 5
Joined
Aug 29, 2011
Messages
306
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
World
Activity points
3,624
Hi

I am currently using 8Mhz ( instruction cycle = 2 Mhz). I know with PLL I can increase this to 32MHZ...but HOW is my question !

Currently I have:

#pragma config OSC = INTIO67

OSCCON = 0b01110010; //select 8 MHz clock

Can someone plzzzzzzzzz tell me how I can increase 8 to 32 MHz!!

Also if and when I do manage to get my Fosc to 32 , would my instruction clock be Fosc/4 = 32/4 = 8Mhz?

Thanks
 

Typically the PLL is configured by the Configuration Settings.

To which PIC are you referring?

BigDog
 

Same old PIC of mine PIC18F4620 !

My frequency counter is giving me 0s , so I though of increasing the Fosc to Max possible (32Mhz)
 

Judging for your other posts, if the PIC in question is the PIC18F4620 the PLL is actually configured via register setting when configured in conjunction with the Internal Oscillator.

Reference: PIC18F2525/2620/4525/4620 Datasheet, Section: 2.6.4 PLL IN INTOSC MODES, Pg. 26


BigDog

---------- Post added at 22:16 ---------- Previous post was at 22:09 ----------

#pragma config OSC = INTIO67

OSCCON = 0b01110010; //select 8 MHz clock

Can someone plzzzzzzzzz tell me how I can increase 8 to 32 MHz!!

You'll also need to enable the PLL via the OSCTUNE register, bit PLLEN.

Example:
Code:
OSCTUNE = 0b01000000;

You should verify the correct #define for the OSCTUNE register is indeed OSCTUNE.


Also if and when I do manage to get my Fosc to 32 , would my instruction clock be Fosc/4 = 32/4 = 8Mhz?

Yes.

BigDog
 
Yup from the data sheet ....In order to enable PLL

1) Work with 4Mhz or 8Mhz ( Checked in OSCCON register)

2) Device is configured to use internal oscillator block as its primary clock source ( OSC = INTIO7 , so that I can see the clock on RA6)

The frequency at RA6 is 2.24 Mhz when it should read 8 MHz ( 32/4)

Code:

/* Clock Setup*/
OSCCON = 0b01110010; //select 8 MHz clock

OSCTUNE = 0b01001111;
 

Code:
 /* Clock Setup*/ 
	OSCCON = 0b01110010; //select 8 MHz clock 
	
	OSCTUNE = 0b01001111;

Why are you changing the factory calibrated frequency of the internal oscillator?

Try:

Code:
OSCTUNE = 0b01000000;

Instead of:

Code:
OSCTUNE = 0b01001111;

Or better yet, try:

Code:
OSCTUNE |= 0b01000000;

Which sets the PLLEN leaving the other bits unchanged.

BigDog
 
Yup that gives me 2 MHz at RA6 .

I was fiddling around with these bits to get MAX frequency out.
OSCTUNE (BIT 4:BIT0)
bit 4-0 TUN4:TUN0: Frequency Tuning bits
01111 = Maximum frequency
• •
• •
00001
00000 = Center frequency. Oscillator module is running at the calibrated frequency.
11111
• •
• •
10000 = Minimum frequenc

---------- Post added at 10:28 ---------- Previous post was at 10:27 ----------

By the way, whats " |= " this?
 


The Oscillator Tuning Bits are usually utilized to compensate for frequency drift due to Vdd or temperature changes.

By the way, whats " |= " this?

The operator "|" is a Bitwise OR and combining them with an assignment operator "=" simplifies the statement.

For example:

Code:
A = A | B;

Is equivalent to:

Code:
A |= B;

Either statement assigns the result of "A OR B" to "A."

BigDog
 
" FOSC3:FOSC0 should be 1001 or 1000 " for PLL to work.....Its only set in the configuration bits I suppose [OSC= INTIO7 or INTIO67]?
 

" FOSC3:FOSC0 should be 1001 or 1000 " for PLL to work.....Its only set in the configuration bits I suppose [OSC= INTIO7 or INTIO67]?

Yes and No.

Yes, if the oscillator source is the internal oscillator, INTIO7 or INTIO67 are the only valid Internal Oscillator settings.

However, if an external clock source is utilized there are of course other valid Configuration Register Settings, HSPLL for High-Speed Crystal/Resonator.

I should also mention, when using an External High-Speed Crystal/Resonator, the PLL is properly configured and enabled via other Configuration Register Settings.


BigDog
 
" FOSC3:FOSC0 should be 1001 or 1000 " for PLL to work.....Its only set in the configuration bits I suppose [OSC= INTIO7 or INTIO67]?

Yup, one and the same..


Code:
TABLE 23-1: CONFIGURATION BITS AND DEVICE IDs         
File Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Default/
Unprogrammed
Value
300001h CONFIG1H IESO FCMEN — — FOSC3 FOSC2 FOSC1 FOSC0 00-- 0111
300002h CONFIG2L — — — BORV1 BORV0 BOREN1 BOREN0 PWRTEN ---1 1111
 
I see , then why don't I get 32Mhz with this?

/* Clock Setup*/
OSCCON = 0b01110010; //select 8 MHz clock
OSCTUNE |= 0b01000000;
 

I see , then why don't I get 32Mhz with this?

/* Clock Setup*/
OSCCON = 0b01110010; //select 8 MHz clock
OSCTUNE |= 0b01000000;



Hi, yes had the same problem , just make OSCON bit 1 a zero and it works fine

Edit, seems it needs to see the Int Osc as primary not int ??

The PLL is available when the device is configured to
use the internal oscillator block as its primary clock
 
OMG that worked! It gives me 8MHz at Ra6 (Fosc = 32 Mhz) =D

Thanks wp100 =)

Going by the data sheet, changing OSCON 10 to 00 switch from Internal Oscillator block to Primary Oscillator - not sure how it works but im happy that it does !

Will go test my frequency setup, hope I can capture my frequency now *fingers crossed*
 

Exactly.

Reference: PIC18F2525/2620/4525/4620 Datasheet, Section: 2.7 Clock Sources and Oscillator Switching, Pg. 28


BigDog
 
Got it!

My frequency counter still gives me 0 but at a faster rate =P

So the problem lies somewhere else I suppose!
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…