PIC32MX Oscillator Configuration

There are two ways to configure the desired oscillator settings:

  • Core Configuration Bits Registers
  • Oscillator Special Function Registers (SFRs)

Configuration Bits Registers

These settings are saved in a special portion of Flash memory and are loaded at the moment power is applied to the microcontroller. By having them instantly available at power-on, we don’t need to waste time and processor cycles setting up the oscillator in our application code.

The configuration bits are defined using #pragma config statements using the MPLAB® C Compiler for PIC32 MCUs.

It is important to first define the signal source for the Primary Oscillator and the target system clock frequency. Following the guidelines in the datasheet, you can then determine the divider values and PLL multipliers required.

The #pragma config statements do not generate any executable code. They define a word that is to be written into the appropriate configuration register address that matches the desired configuration option. This word will be written into the PIC32's Flash memory when the device is programmed and is stored in the application's HEX file generated by MPLAB IDE.

To determine which options are allowed with the #pragma config statements, refer to the hlpPIC32MXConfigSet.chm file, and search for the exact PIC32 microcontroller you are using.

Refer to C:\Program Files\Microchip\xc32\<ver>\docs\PIC32ConfigSet.html for a listing of all #pragma config macros available for your MCU.

Refer to the "Special Features" section of the MCU datasheet to learn about all the configurable hardware options on the device.


During run-time, it is possible to change the clock source, modify the oscillator settings, check the status of the various oscillator sources, and determine whether the PLLs are locked.

The Oscillator Family Reference Manual provides basic C-code examples that show how to configure these registers for specific applications.

Alternatively, you can use the MPLAB Harmony library Application Programming Interfaces (APIs) to dynamically change oscillator configuration.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.