16-Bit Oscillator System: 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. 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).

Application code will need to verify that the switch has completed.

The following MPLAB® XC16 compiler code example enables two-speed start-up (FRC to 8 MHz XTAL POSC) for a PIC24FJ128GA010 MCU:

#include <xc.h>

#pragma config FNOSC = PRI // Primary Oscillator desired
#pragma config POSCMOD = XT // XT Oscillator mode selected
#pragma config IESO = ON  // Two-Speed Start-Up enabled

int main(void)
{
    // compare the current OSC with new OSC - when these bits match, the clock switch is complete     
    while(OSCCONbits.COSC != OSCCONbits.NOSC);
    ...
}

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.

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