A dedicated low-power 32.768 kHz oscillator circuit is built-in between pins SOSCI (input) and SOSCO (amplifier output). This internal circuit requires an external 32.768 kHz "clock" crystal to operate. This oscillator is designed as a clock source to feed the Timer 1 module and enable the PIC® MCU device to create time keeping applications. The oscillator can also be used as a secondary system clock when Clock Switching is enabled.
One advantage to this clock source is the oscillator will continue to run during Sleep mode so the time keeping can continue to operate at low power.
Enabling Timer 1 Secondary Oscillator
Setting the Oscillator Enable Control (T1OSCEN) bit in the Timer 1 Control (T1CON) register will enable the oscillator drive circuitry.
Oscillator Start-up Delay
The oscillator requires a start-up and stabilization time before use. Thus, the T1OSCEN bit should be set and a suitable
delay similar to the Oscillator Start-up Timer (OST) delay can be implemented in software by clearing the Timer 1 Interrupt Flag (TMR1IF) bit in the Peripheral Interrupt Register (PIR) and then presetting the Timer 1 High (TMR1H) and Timer 1 Low (TMR1L) register pair to a hexadecimal value of FC00. The TMR1IF flag will be set when 1024 clock cycles have elapsed, thereby indicating that the oscillator is running and reasonably stable.
For more information on 8-Bit oscillator options visit the 8-Bit Oscillator Options article.