Introduction
The Numerically Controlled Oscillator (NCOx) module is a timer that uses the overflow of an accumulator to create an output signal. The accumulator overflow is controlled by an adjustable increment value rather than just a single clock pulse or postscaler increment. This offers an advantage over a simple timer driven counter in that the resolution of division does not vary with the somewhat limited prescaler/postscaler divider value. The NCOx is most useful for applications that require frequency accuracy and fine resolution at a fixed duty cycle.
Features of the NCOx include:
- 16-bit increment function
- Fixed Duty Cycle (FDC) mode
- Pulse Frequency (PF) mode
- Output pulse width control
- Multiple clock input sources
- Output polarity control
- Interrupt capability
The NCOx operates by repeatedly adding a fixed value to an accumulator. Additions occur at the input clock rate. The accumulator will overflow with a carry periodically, which is the raw NCOx output. This effectively reduces the input clock by the ratio of the added value to the maximum accumulator value.
The NCOx output can be further modified by stretching the pulse or toggling a flip-flop. The modified NCOx output is then distributed internally to other peripherals and optionally output to an I/O pin. The accumulator overflow can also generate an interrupt. The NCOx period changes in discrete steps to create an average frequency. This output depends on the ability of the receiving circuit (i.e., CWG or external resonant converter circuitry) to average the NCOx output to reduce uncertainty.
The overflow of the NCO module is based on the formula below:

