News:

Let's find out together what makes a PIC Tick!

Main Menu

Help with configuring Osc on the 12F1822

Started by JohnB, Sep 26, 2025, 10:30 AM

Previous topic - Next topic

JohnB

Attached is my code for a small board I have made.  The code works fine in ISIS (see attached project) but in practice it seems to be running slow.  With no inputs the Carrier Watchdog should trigger which it does but its flashing about half the rate.  I can't measure this as I have a problem with my scope. Have I got the correct oscilator settings for an 8mHz clock?
JohnB

Maxi

here is my working code for 8MHZ

Device = 12F1822
Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_OFF, CP_OFF, CPD_OFF, BOREN_OFF, CLKOUTEN_OFF, IESO_OFF, FCMEN_OFF
Config2 WRT_OFF, PLLEN_OFF, STVREN_OFF, BORV_19, LVP_OFF
Declare Xtal=8

OSCCON.6=1
OSCCON.5=1
OSCCON.4=1
OSCCON.3=0

OSCCON.1=1

Stephen Moss

I had a quick look and it appears you have the PLL enabled in the config fuse, and 8MHz selected as the internal Oscillator frequency, theoritically that would make the frequency 32MHz and you have specified the Xtal frequency as 8MHz so there is a discrepency there.

Additioanlly, if 8MHz is what you want and for it to be sourced from the internal oscillator, I think you have the set the PLL_EN bit of the config fuse to 0 (Disabled) as section 5.2.2.6 states...
When using the PLLEN bit of the Configuration Word 2, the 4xPLL cannot be disabled by software and the 8 MHz HFINTOSC option will no longer be available.

I could not see where it specified what the ouput of the internal oscillator would be when you select 8MHz and have the PLL_EN bit set, but I may have missed it as I was quickly scanning through the Oscillator section.
If you want to use the PLL with the 8MHz output from the internal oscillator to me it appears that you need to have the PLL disabled in the config fuses and use the SPLLEN bit of the OSCTUNE register to enable it and change your Xtal declare to from 8 to 32.

JohnB

Thanks, I now have the board and the ISIS behaving simmilarly.
JohnB