dsPIC33A Oscillator Module Deep Dive
Reference Clocks
| Clock Monitor Example Project | Oscillators |
Overview
The dsPIC33AK512MPS512 family provides one or more Reference Clock Input (REFIx) and Output (REFOx) functions.
In simple terms, REFO allows an internal clock source to be routed out to a device pin for external use, debugging, synchronization, or clock measurement.

Each REFOx module is driven by an assigned Clock Generator (CLKGEN). As a result, the REFO output frequency is based on the clock source selected for that CLKGEN, which can be any supported internal or external clock source.
Key points:
- REFI1 and REFI2 are pin-remappable using Peripheral Pin Select (PPS)
- REFO1 and REFO2 are also pin-remappable through PPS, but each is associated with a specific CLKGEN
Two clock generators are reserved specifically for REFO operation. These REFO-dedicated CLKGENs operate similarly to the other clock generators and can also serve as clock sources for other CLKGEN modules.
REFIx and REFOx Application Examples

REFIx can be used to:
- Bring an external reference clock into the device
- Synchronize with another system clock
- Support clock monitoring and measurement applications
REFOx can be used to:
- Output an internal clock to a device pin
- Observe or validate system clock behavior
- Provide a clock source to external devices
- Support debugging and timing analysis
Together, REFI and REFO provide flexible clock input and output capabilities for system synchronization, monitoring, and validation. Potential applications could range from a unique clock for a Smart Card clock to a Master Clock (MCLK) for an audio reference.
Reference Clocks: Example PPS Configuration
REFI1: Pin Remap
In this example, we want to map the REFI1 input function to re-mappable pin RP103/RG6 on the 128-pin version of dsPIC33AK512MPS512.
REFI1 function mapping is controlled by SFR RPINR18 (Peripheral Pin Select Input Register 18):
For this example, the source code to complete the mapping looks like this:
_TRISG6 = 1; // set pin "RG6" as an input
This allows an external reference clock to be routed into the device for clock generation, monitoring or synchronization applications.
REFO2: Pin Remap
In this example, we want to map the REFO2 output function to re-mappable pin RP38/RC5 on the 128-pin version of dsPIC33AK512MPS512.
REFO2 function mapping is controlled by SFR RPOR9 (Peripheral Pin Select Output Register 9, which sets the output pin function for pin RP38):
For this example, the source code to complete the mapping looks like this:
_TRISC5 = 0; // set pin "RC5" as output
CLK14CONbits.OE = 1; // CLKGEN14 enable onto pin