PIC32 Oscillator - Two-Speed Start-up

Two-Speed Start-up

If an external crystal (Primary Oscillator) is providing a clock source for your device, you will need to wait for the oscillator and PLL to stabilize before executing any code after a Power-on Reset (POR) or exit from sleep (see Oscillator Start-up Timer and System PLL Lock Status for more information). If you want to start executing code before the oscillator has stabilized, you can use the "Two-Speed Start-up" option.

Two-Speed Start-up uses the internal Fast RC Oscillator (FRC) as the system clock source until the Primary Oscillator (POSC) has stabilized. This allows the CPU to begin running code while the oscillator is stabilizing. After it has stabilized, the clock source will automatically be switched to use the Primary Oscillator (POSC).

If you want to determine the clock source currently in use, the MPLAB® Harmony function shown in the example below can be used. It will return the current oscillator (COSC) setting found in the OSCCON register.

// Enable Two-Speed Start-up (Internal/External switch over)
#pragma config IESO = ON
...
// variable to hold the state of the current clock source
OSC_SYS_TYPE oscCurrent;
// assign the current clock source to oscCurrent
oscCurrent = PLIB_OSC_CurrentSysClockGet(OSC_ID_0);
                                              // 0 = FRC
                                              // 2 = POSC
                                              // 3 = POSC with PLL

The Watchdog Timer (WDT), if enabled, will continue to count at the same rate regardless of the SYSCLK frequency. Care must be taken to service the WDT during Two-Speed Start-up, taking into account the change in SYSCLK.

Detailed Overview

For more detail on the Two-Speed Start-up feature, please view the Oscillator family reference manual chapter for that device, for example:

The device data sheet should then be consulted to verify the specific features implemented in that device.

© 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.