12.4.3 Primary Oscillator (POSC)
The dsPIC33AK128MC106 devices contain one instance of the Primary Oscillator (POSC). The Primary Oscillator is available on the OSCO and OSCI pins of the dsPIC33A devices. This connection enables an external crystal (or ceramic resonator) to provide the clock to the device. The Primary Oscillator has three modes of operation listed in Table 12-33.
POSCMD[1:0] bits in OSCCFG register | Mode Description |
---|---|
3 | POSC is disabled. OCSI can be used as regular I/O pins. The OSCO pin is controlled by the POSCIOFNC bit in the OSCCFG register. |
2 | High Gain Mode. The gain may be sufficient to work with a high-frequency crystal up to 32 MHz. OSCO and OSCI pins are connected to a crystal oscillator driver. |
1 | Normal Gain Mode. The gain may be sufficient to work with 3.5 MHz to 10 MHz crystals. The OSCO and OSCI pins are connected to a crystal oscillator driver. |
0 | External Clock Mode (EC). The clock source must be connected to the OSCI pin. The OSCO pin is controlled by the POSCIOFNC bit in the OSCCFG register. |
If the Primary Oscillator is disabled or configured in EC mode, the OSCO pin can output the device system (CPU) clock when the POSCIOFNC bit in the OSCCFG register is set.
Figure 12-9 shows a recommended Pierce oscillator circuit diagram for the dsPIC33A devices.
Capacitors C1 and C2 form a load capacitance (CLOAD) for the crystal, and the R1 resistor limits the power dissipated in the quartz. The optimum load capacitance for a given crystal is specified by the crystal manufacturer. Load capacitance can be calculated as shown in Equation 12-6.

Where CSTRAY is the stray capacitance between the quartz crystal pads on the board (in many cases, it can be assumed 1-3 pF), C1 and C2 are capacitors connected to the crystal.
Assuming that C1 = C2, Equation 12-7 gives the capacitors C1 and C2 values for a given crystal load and stray capacitance.

Where CLOAD is a nominal load capacitance from the crystal spec, and CSTRAY is the stray capacitance between the quartz crystal pads on the board.
If the power dissipated in the crystal is higher than the value specified by the crystal manufacturer, the current must be limited by resistor R1 to avoid overdriving the crystal. An initial estimation of R1 can be obtained by considering the voltage divider formed by R1 and C1. Thus, the initial value of R1 is equal to the impedance of C1 as shown in Equation 12-8.
Where F is the crystal nominal oscillation frequency.
The power dissipating in quartz can be verified with an oscilloscope using Equation 12-9.
Where RESR is the series resistance from the crystal space, R1 is the current-limiting resistor, F is the crystal nominal oscillation frequency, CSTRAY is the stray capacitance between the quartz crystal pads on the board, CPROBE is the capacitance of the oscilloscope probe connected to CR, and Vpp is the peak-to-peak amplitude of the signal on the C2 capacitor measured with an oscilloscope.
The calculated power must be less than what is specified in the crystal specification.
The Primary Oscillator gain is selected by the POSCMD[1:0] and GAIN[1:0] bits. For each
gain mode, normal and high (POSCMD[1:0] = 1
and POSCMD[1:0] =
2
), the GAIN[1:0] bits set the oscillator driver transconductance
level as specified in the electrical specifications.
The transconductance of the crystal oscillator driver, required to start the oscillation quickly enough and sustain stable oscillation, must be about four times greater than the transconductance of the quartz crystal circuit.
The transconductance of the quartz crystal circuit can be estimated by using Equation 12-10.
Where RESR is the equivalent series resistance from the crystal spec, R1 is a power-limiting resistor, F is the crystal nominal oscillation frequency, CSTRAY is the stray capacitance between the quartz crystal pads on the board, and COSC/2 is the external load capacitance for the crystal.
The transconductance selected by GAIN[1:0] bits should be at least four times larger than the calculated Gmin; however, gain settings that are too high may overload the crystal.
To accelerate the start of the oscillation, the KICKSTART bit in the OSCCFG register can be set. When this bit is set, the gain of the crystal driver is set to maximum temporary for a short start-up time.