The Internal Oscillator Mode uses two independent oscillators and a dedicated High Frequency Phase Locked Loop (HFPLL) to create three internal oscillator clocks.
The three blocks include:
- HFINTOSC - High Frequency Internal Oscillator (factory calibrated to run at 16 MHz). This oscillator is derived from the 500 kHz source and the HFPLL.
- MFINTOSC - Medium Frequency Internal Oscillator (factory calibrated to run at 500 kHz).
- LFINTOSC - Low Frequency Internal Oscillator (uncalibrated 31 kHz clock source). This is the same oscillator used for the Watchdog Timer, Power-up Timer and Fail-Safe Clock Monitor.
The HFINTOSC and MFINTOSC are routed through a multiplexer to produce a range of frequencies than can be selected with three bits in the OSCCON register.
The range includes:
- 16 MHz (HFINTOSC)
- 8 MHz
- 4 MHz
- 2 MHz
- 1 MHz
- 500 kHz (MFINTOSC)
- 250 kHz
- 125 kHz
- 62.5 kHz
- 31.25 kHz
- 31 kHz (LFINTOSC)
These are selected through the IRCF bits of the OSCCON register.
The Internal Oscillator is enabled by one of two methods:
- Set the Fosc bits in a configuration register to select the internal oscillator
- Set the SCS bits in the OSCCON register to select the internal oscillator
The OSC1 and OSC2 pins are available as general purpose I/O when the internal oscillator is selected. The OSC2 pin can also be used to output the instruction clock with a configuration setting.
Internal Oscillator Setup
To select the internal oscillator with the Fosc bits in a configuration register, the INTOSC is selected via the Fosc bits.
Note: The SCS bits of the OSCCON register must also be set to "Clock Determined by FOSC" selection.
To select the internal oscillator with just the SCS bits in the OSCCON register, the "Internal Oscillator Block" associated bits are selected.
OSC2 Pin Clock Out Option
The CLKOUTEN bit is also in a configuration register and typically in the same register as the Fosc bits.
Note: On older devices the OSC2 clock out option is incorporated into the Fosc settings instead of a separate CLKOUTEN bit to set.
Selecting the Oscillator Speed
Once the internal oscillator is enabled the internal oscillator frequency select (IRCF) bits in the Oscillator Control Register (OSCCON) are set to select the oscillator frequency. The four bits select one of 15 different oscillator selections.
Internal Oscillator Start-up
The Internal Oscillator start-up is very quick and the internal oscillator will run the device at start-up if it is selected as the main oscillator, Two Speed Start-up is enabled or Fail-Safe Clock Monitor is enabled. The status of the internal oscillator can be monitored through the Oscillator Start-up Timer Status bit (OSTS) in the OSCSTAT register. It will be cleared when the internal oscillator is running.
32 MHz Oscillator
A 32 MHz source can be created by routing the 8 MHz output through an external 4x PLL which is available on many devices. The following settings must be established to run on an internal 32 MHz system clock:
- The Fosc bits in a Configuration register must be set to INTOSC selection
- The SCS bits in the OSCCON register must be cleared to use the "Clock determined by Fosc" setting
- The IRFC bits in the OSCCON register must select the 8 MHz HFINTOSC
- The SPLLEN bit in the OSCCON register must be set to enable the 4x PLL
A 32 MHz oscillator will result in an 8 MHz instruction clock (Fosc/4) after the divide by four operation in the oscillator block.
Internal Oscillator Frequency Adjustment
The OSCTUNE register can alter the frequency of the HFINTOSC and MFINTOSC through minor adjustments. The OSCTUNE contains a 6-bit value that can adjust the frequency within a range of +/-12 % of the selected frequency. The upper range of tuning in the OSCTUNE register are values; 01h - 1Fh. The lower range of tuning in the OSCTUNE register are the values; 20h - 3Fh. With the OSCTUNE set to 00h, the internal oscillator frequency will not be affected.
For more detail on adjusting the internal oscillator with the OSCTUNE register refer to application note AN244.