8-bit PIC® MCU Timer1 Sleep Operation

Last modified by Microchip on 2023/11/09 09:03

Timer1 can only operate during Sleep when set up in Asynchronous mode. In this mode, an external crystal or clock source can be used to increment the counter. To set up the timer to wake the device:

  • Set the TMR1ON bit of the T1CON register
  • Set the TMR1IE bit of the PIE1 register
  • Set the PEIE bit of the INTCON register
  • Set the T1SYNC bit of the T1CON register
  • Configure the TMR1CS bits of the T1CON register
  • Configure the T1OSCEN bit of the T1CON register

The device will wake up on a Timer1 overflow and execute the instructions following the SLEEP assembly command.

The wake-up from Sleep can also drive the device to execute the Interrupt Service Routine instead of the instruction following the sleep command. To enable this, the Global Interrupt Enable (GIE) bit of the INTCON register needs to be set. The device will call the Interrupt Service Routine on wake-up. If the interrupt service routine contains a SLEEP instruction, the device will return to Sleep mode. The service routine must also clear the TMR1IF prior to returning to Sleep.