10.4 Primary Oscillator (POSC)

The dsPIC33CK512MPT608 family devices contain one instance of the Primary Oscillator (POSC). The Primary Oscillator is available on the OSCI and OSCO pins of the dsPIC33CK devices. This connection enables an external crystal (or ceramic resonator) to provide the clock to the device. The Primary Oscillator provides three modes of operation:

  • Medium Speed Oscillator (XT Mode):
The XT mode is a Medium Gain, Medium 
Frequency mode used to work with crystal 
frequencies of 3.5 MHz to 10 MHz.
  • High-Speed Oscillator (HS Mode):
The HS mode is a High-Gain, High-Frequency mode used to work with crystal frequencies of 10 MHz to 32 MHz.
  • External Clock Source Operation (EC Mode):
If the on-chip oscillator is not used, the EC mode allows the internal oscillator to be bypassed. The device clocks are generated from an external source (0 MHz to up to 64 MHz) and input on the OSCI pin.

Code for Using PLL (50 MIPS) with Primary Oscillator (POSC) illustrates code for using the PLL (50 MIPS) with the Primary Oscillator.

Code for Using PLL (50 MIPS) with Primary Oscillator (POSC)

//code example for 50 MIPS system clock using POSC with 10 MHz external crystal
// Select FRC on POR
#pragma	config   FNOSC = FRC    // Oscillator Source Selection (Internal Fast RC (FRC))
#pragma	config   IESO = OFF
/// Enable Clock Switching and Configure POSC in XT mode
#pragma	config   POSCMD = XT
#pragma	config   FCKSM = CSECMD
int          main()
{
		// Configure PLL prescaler, both PLL postscalers, and PLL feedback divider
		CLKDIVbits.PLLPRE = 1;     // N1=1
		PLLFBDbits.PLLFBDIV = 100; // M = 100
		PLLDIVbits.POST1DIV = 5;   // N2=5
		PLLDIVbits.POST2DIV = 1;   // N3=1
		// Initiate Clock Switch to Primary Oscillator with PLL (NOSC=0b011)
		__builtin_write_OSCCONH(0x03);
		__builtin_write_OSCCONL(OSCCON | 0x01);
		// Wait for Clock switch to occur
		while (OSCCONbits.OSWEN!= 0);
		// Wait for PLL to lock
		while (OSCCONbits.LOCK!= 1);
}