PIC18F6722 - Oscillator Configurations.

0.Contents

1.Internal Oscillator - INTOSC - INTOSC/PLL.

// Configuration registers.
#pragma config FCMEN = ON, IESO = OFF, OSC = INTIO7
#pragma config BOREN = SBORDIS, BORV = 3, PWRT = OFF
#pragma config WDTPS = 32768, WDT = OFF
#pragma config LPT1OSC = OFF, MCLRE = ON, CCP2MX = PORTC
#pragma config STVREN = ON, LVP = ON, BBSIZ = BB2K, XINST = OFF
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
#pragma config CP4 = OFF, CP5 = OFF, CP6 = OFF, CP7 = OFF
#pragma config CPB = OFF, CPD = OFF
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF
#pragma config WRT4 = OFF, WRT5 = OFF, WRT6 = OFF, WRT7 = OFF
#pragma config WRTC = OFF, WRTB = OFF,WRTD = OFF
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF
#pragma config EBTR4 = OFF, EBTR5 = OFF, EBTR6 = OFF, EBTR7 = OFF
#pragma config EBTRB = OFF

#include <xc.h>
// PIC18F6722 - Compile with XC8(v1.44).
// Internal Oscillator - INTOSC - INTOSC/PLL

// Definitions.
#define PROBE		LATAbits.LATA0
#define PROBE_TRIS	TRISAbits.TRISA0

// Main.
int main(void)
{
	PROBE = 0;
	PROBE_TRIS = 0;

	// Internal Oscillator Frequency Select bits.
	// IRCF2.0 = 1 1 1 - 8MHz.
	// IRCF2.0 = 1 1 0 - 4MHz.
	// IRCF2.0 = 1 0 1 - 2MHz.
	// IRCF2.0 = 1 0 0 - 1MHz.
	// IRCF2.0 = 0 1 1 - 500kHz.
	// IRCF2.0 = 0 1 0 - 250kHz.
	// IRCF2.0 = 0 0 1 - 125kHz.
	// IRCF2.0 = 0 0 0 - 31kHz.
	OSCCONbits.IRCF2 = 0;
	OSCCONbits.IRCF1 = 0;
	OSCCONbits.IRCF0 = 0;
	// System Clock select bits.
	// SCS1.0 = 1 0 - Internal oscillator.
	// SCS1.0 = 0 1 - Secondary (Timer1) oscillator.
	// SCS1.0 = 0 0 - Primary oscillator.
	OSCCONbits.SCS1 = 0;
	OSCCONbits.SCS0 = 0;
	// Frequency Tunning.
	// TUN4.0 = 0 1 1 1 1 - Maximum frequency.
	// TUN4.0 = 1 0 0 0 0 - Minimum frequency.
	OSCTUNE = 0b00000000;
	// INTRSC - Internal Oscillator Low-Frequency source select bit.
	// INTRSC0 = 0 - 31KHz device clock derived from INTRC internal source.
	// INTRSC0 = 1 - 31.25KHz KHz device clock derived from 8MHz INTOSC source.
	OSCTUNEbits.INTSRC = 0;
	// PLL - Frequency Multiplier PLL for INTOSC Enable bit.
	// PLLEN0 = 0 - PLL Disabled.
	// PLLEN0 = 1 - PLL Enabled for INTOSC 4MHz & 8MHz only.
	OSCTUNEbits.PLLEN = 0;
	// IOFS - INTOSC Frequency stable bit.
	while(!OSCCONbits.IOFS);
	
	while(1){
		PROBE ^= 1;
	}
	return(0);
}
Fosc = 31kHz - INTSRC = 1 - IRCF2.0 = 0 0 0 - PLLEN = 0.
Fosc = 125kHz - IRCF2.0 = 0 0 1 - PLLEN = 0.
Fosc = 250kHz - IRCF2.0 = 0 1 0 - PLLEN = 0.
Fosc = 500kHz - IRCF2.0 = 0 1 1 - PLLEN = 0.
Fosc = 1MHz - IRCF2.0 = 1 0 0 - PLLEN = 0.
Fosc = 2MHz - IRCF2.0 = 1 0 1 - PLLEN = 0.
Fosc = 4MHz - IRCF2.0 = 1 1 0 - PLLEN = 0.
Fosc = 8MHz - IRCF2.0 = 1 1 1 - PLLEN = 0.
Fosc = 16MHz - IRCF2.0 = 1 1 0 - PLLEN = 1.
Fosc = 32MHz - IRCF2.0 = 1 1 1 - PLLEN = 1.

2.External Oscillator High-Speed Crystal/Resonator - HS

// Configuration registers.
#pragma config FCMEN = ON, IESO = OFF, OSC = HS
#pragma config BOREN = SBORDIS, BORV = 3, PWRT = OFF
#pragma config WDTPS = 32768, WDT = OFF
#pragma config LPT1OSC = OFF, MCLRE = ON, CCP2MX = PORTC
#pragma config STVREN = ON, LVP = ON, BBSIZ = BB2K, XINST = OFF
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
#pragma config CP4 = OFF, CP5 = OFF, CP6 = OFF, CP7 = OFF
#pragma config CPB = OFF, CPD = OFF
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF
#pragma config WRT4 = OFF, WRT5 = OFF, WRT6 = OFF, WRT7 = OFF
#pragma config WRTC = OFF, WRTB = OFF,WRTD = OFF
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF
#pragma config EBTR4 = OFF, EBTR5 = OFF, EBTR6 = OFF, EBTR7 = OFF
#pragma config EBTRB = OFF

#include <xc.h>
// PIC18F6722 - Compile with XC8(v1.44).
// External Oscillator - HS.

// Definitions.
#define PROBE		LATAbits.LATA0
#define PROBE_TRIS	TRISAbits.TRISA0

// Main.
int main(void)
{
	PROBE = 0;
	PROBE_TRIS = 0;
	
	while(1){
		PROBE ^= 1;
	}
	return(0);
}
Fosc = 8MHz.

3.External Oscillator High-Speed Crystal/Resonator - HSPLL

// Configuration registers.
#pragma config FCMEN = ON, IESO = OFF, OSC = HSPLL
#pragma config BOREN = SBORDIS, BORV = 3, PWRT = OFF
#pragma config WDTPS = 32768, WDT = OFF
#pragma config LPT1OSC = OFF, MCLRE = ON, CCP2MX = PORTC
#pragma config STVREN = ON, LVP = ON, BBSIZ = BB2K, XINST = OFF
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
#pragma config CP4 = OFF, CP5 = OFF, CP6 = OFF, CP7 = OFF
#pragma config CPB = OFF, CPD = OFF
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF
#pragma config WRT4 = OFF, WRT5 = OFF, WRT6 = OFF, WRT7 = OFF
#pragma config WRTC = OFF, WRTB = OFF,WRTD = OFF
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF
#pragma config EBTR4 = OFF, EBTR5 = OFF, EBTR6 = OFF, EBTR7 = OFF
#pragma config EBTRB = OFF

#include <xc.h>
// PIC18F6722 - Compile with XC8(v1.44).
// External Oscillator - HSPLL.

// Definitions.
#define PROBE		LATAbits.LATA0
#define PROBE_TRIS	TRISAbits.TRISA0

// Main.
int main(void)
{
	PROBE = 0;
	PROBE_TRIS = 0;

	while(1){
		PROBE ^= 1;
	}
	return(0);
}
Fosc = 8MHz x 4 = 32MHz.

11.2017