Clock Switching

The system clock source can be switched between an internal and external source via control bits in the OSCCON register. This allows the PIC® MCU device to control the speed of the operation and can also help with power reduction. A slower oscillator will draw less current than a higher speed oscillator. During normal operation, a higher speed may be needed but when the application is less active, a slower oscillator may be able to handle the processing duties. This will reduce the power consumption. Various sleep options are available for very low power but its often necessary to maintain continuous operation during sleep. A slower oscillator speed may be all that is required during this sleep mode operation.

The clock switching feature on many devices can be controlled from the application software. There are three choices that can be selected for the system clock via the clock switching feature. They include:

Note: Clock Switching is a software application controlled operation and not an automatic operation. Other clock switching functions such as Fail Safe Clock Monitor and Two Speed Start-Up are automatic clock switching features that do not affect the clock switching settings.

clockswitch.png

Clock Switching Control

The Clock Switching mode is controlled by the SCS bits in the OSCCON register. These bits can be changed via software during run time to change the clock source.

oscconscs.png
scsbits.png

When the SCS bits = 00, the system clock is switched to the clock source selected by the Fosc bits in the Configuration Register. This can be the Internal Oscillator, External Crystal/Resonator or External Clock .

When the SCS bits = 01, the system clock is switched to the Secondary Oscillator which is an external 32.768 Khz crystal that controls the Timer1 Peripheral. The external clock crystal is an optional clock source that must be part of the Timer1 design circuit.

When the SCS bits = 10 or 11, then the system clock is switched to Internal Oscillator independent of the Fosc configuration bit settings. The IRCF bits of the OSCCON register will select the internal oscillator frequency.

Oscillator Status Bits

When switching to a new clock source, its recommended to check the status of the clock source before switching. Each oscillator selection has a status bit in the OSCSTAT Register to indicate if it is ready or if the expected accuracy is achieved. If a device was in sleep mode, where an oscillator may have been shut down to save power, there may be a delay in the clock source being ready for a clock switch. A check of the specific clock source status bit in the OSCSTAT register will determine if the source is ready for the clock switch.

oscstatreg.png
oscstatbits.png

Fosc Status

The OSTS bit indicates the status of the oscillator selected by the Fosc configuration bit settings. After a reset, the INTOSC internal oscillator may be controlling the device while the Fosc selection completes it's start-up delay or even the Power-Up Timer delay. Checking the OSTS bit will indicate which oscillator is controlling the device.


For more information on 8-Bit oscillator options visit the 8-Bit Oscillator Options article.

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