[PIC] Can't Figure out how to set 32MHZ Internal Oscillator for PIC16F1847

Status
Not open for further replies.

asking

Full Member level 5
Joined
Sep 21, 2010
Messages
279
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Visit site
Activity points
3,377
Hi,

I am trying to run PIc16F1847 @ full speed of 32MHZ. I have set the register's as below. I am not able to understand properly datasheet. so kindly help me. The below data is true for 32mhz or am i doing something..wrong ?

Code:
OSCCON = 0xF2; // INTOSC 32MHZ
OSCTUNE = 0X1F; // MAX FREQUNCY

But i am not sure how to check whether my PIC is running @ 32MHZ or at what frequency ? how to check with oscilloscope ?

Thanks.
 

There are two issues with the code snippet you have posted:

Code:
OSCCON = 0xF2; // INTOSC 32MHZ
[COLOR="#FF0000"]OSCTUNE = 0X1F; // MAX FREQUNCY[/COLOR]

Firstly, in this case this is no need to alter the value contained in the OSCTUNE register, it is akin to the vernier adjustment on a scope, intended to fine tune the oscillator frequency out of calibration, leave it set to the startup value of 0x00.

Reference: **broken link removed**, Section: 5.2.2.3 Internal Oscillator Frequency Adjustment, Page:57

Code:
[COLOR="#FF0000"]OSCCON = 0xF2; // INTOSC 32MHZ[/COLOR]
OSCTUNE = 0X1F; // MAX FREQUNCY

Secondly, some of the settings required to configure a 32MHz FOSC using the internal oscillator can either be set using the configuration registers or OSCCON register, the specific details depend on your startup configuration register settings, specifically, the FOSC bits and the PLLEN bit, which should be set to INTOSC and ON masks respectfully.

If the configuration registers are configured as outlined above, setting the bits SCS<1:0> = "00" of the OSCCON register, the default on powerup and reset, and setting the bits IRCF<3:0> = "1110" of the OSCCON register, 8MHz OSC setting, or OSCCON = "0x70" should achieve a 32MHz FOSC.

If the configuration registers are set as outlined above:
Code:
OSCCON = 0x70;

NOTE: If the PLL is not enabled in the configuration register settings, then the SPLLEN bit of the OSCCON register will need to be set as well:
Code:
OSCCON = 0xF0;

Reference: **broken link removed**, Section: 5.2.2.6 32 MHz Internal Oscillator Frequency Selection, Page: 58



BigDog
 
Reactions: asking

    asking

    Points: 2
    Helpful Answer Positive Rating
Awesome That's Fruitful guide for noob like me Thanks for information. I found it was issue that i did not on the PLL in the Mikroc configuration. After Enabling PLL and Setting the OSCCON Configuration i managed to get it running @ 32MHZ.

Wonderful Thanks alot..
 

The FOSC frequency can be safely verified with a scope with passive probe by properly configuring Reference Clock or CLKOUT feature in the configuration registers and monitoring the clock output on the appropriate port pin.

Reference: **broken link removed**, Section: 6.0 REFERENCE CLOCK MODULE, Page: 69


BigDog
 

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…