5.3.3 Clock Switch and Sleep

If OSCCON1 is written with a new value and the device is put to Sleep before the switch completes, the switch will not take place and the device will enter Sleep mode.

When the device wakes from Sleep and the CSWHOLD bit is clear, the device will wake with the ‘new’ clock active, and the Clock Switch Interrupt Flag (CSWIF) bit will be set.

When the device wakes from Sleep and the CSWHOLD bit is set, the device will wake with the ‘old’ clock active and the new clock will be requested again.

Figure 5-6. Clock Switch (CSWHOLD = 0)
Note:
  1. CSWIF is asserted coincident with NOSCR; interrupt is serviced at OSC #2 speed.
  2. The assertion of NOSCR is hidden from the user because it appears only for the duration of the switch.
Figure 5-7. Clock Switch (CSWHOLD = 1)
Note:
  1. CSWIF is asserted coincident with NOSCR, and may be cleared before or after clearing CSWHOLD = 0.
Figure 5-8. Clock Switch Abandoned
Note:
  1. CSWIF may be cleared before or after rewriting OSCCON1; CSWIF is not automatically cleared.
  2. ORDY = 0 if OSCCON1 does not match OSCCON2; a new switch will begin.