Timer1 and it's Programming

TIMER1 Module

The Timer1 timer/counter module incorporates these features:

  • Software selectable operation as a 16-bit timer or counter
  • Readable and writable 8-bit registers (TMR1H and TMR1L)
  • Selectable clock source (internal or external) with device clock or Timer1 oscillator internal options
  • Interrupt-on-overflow
  • Reset on CCP Special Event Trigger
  • Device clock status flag (T1RUN)

A simplified block diagram of the Timer1 module is shown in Figure  The module incorporates its own low-power oscillator to provide an additional clocking option. The Timer1 oscillator can also be used as a low-power clock source for the microcontroller in power-managed operation. Timer1 can also be used to provide Real-Time Clock (RTC) functionality to applications with only a minimal addition of external components and code overhead. Timer1 is controlled through the T1CON Control register. It also contains the Timer1 Oscillator Enable bit (T1OSCEN). Timer1 can be enabled or disabled by setting or clearing control bit, TMR1ON (T1CON<0>). 


7RD16: 16-Bit Read/Write Mode Enable bit
  • 1 = Enables register read/write of TImer1 in one 16-bit operation
  • 0 = Enables register read/write of Timer1 in two 8-bit operations 
6T1RUN: Timer1 System Clock Status bit
  • 1 = Device clock is derived from Timer1 oscillator
  • 0 = Device clock is derived from another source
5-4T1CKPS<1:0>: Timer1 Input Clock Prescale Select bits
  • 11 = 1:8 Prescale value
  • 10 = 1:4 Prescale value
  • 01 = 1:2 Prescale value
  • 00 = 1:1 Prescale value 
3T1OSCEN: Timer1 Oscillator Enable bit
  • 1 = Timer1 oscillator is enabled
  • 0 = Timer1 oscillator is shut off The oscillator inverter and feedback resistor are turned off to eliminate power drain. 
2T1SYNC: Timer1 External Clock Input Synchronization Select bit
  • When TMR1CS = 1
    • 1 = Do not synchronize external clock input
    • 0 = Synchronize external clock input
  • When TMR1CS = 0 
    • This bit is ignored. Timer1 uses the internal clock when TMR1CS = 0. 
1TMR1CS: Timer1 Clock Source Select bit 1 = External clock from pin RC0/T1OSO/T13CKI (on the rising edge) 0 = Internal clock (FOSC/4) 
0TMR1ON: Timer1 On bit
  • 1 = Enables Timer1
  • 0 = Stops Timer1

Timer1 Block Diagram

timer1 block diagram

Timer1 Operation

Timer1 can operate in one of these modes:

  • Timer
  • Synchronous Counter
  • Asynchronous Counter

The operating mode is determined by the clock select bit, TMR1CS (T1CON<1>). When TMR1CS is cleared (= 0), Timer1 increments on every internal instruction cycle (FOSC/4). When the bit is set, Timer1 increments on every rising edge of the Timer1 external clock input or the Timer1 oscillator, if enabled. When Timer1 is enabled, the RC1/T1OSI and RC0/ T1OSO/T13CKI pins become inputs. This means the values of TRISC<1:0> are ignored and the pins are read as ‘0’.

Timer1 Oscillator

An on-chip crystal oscillator circuit is incorporated between pins T1OSI (input) and T1OSO (amplifier output). It is enabled by setting the Timer1 Oscillator Enable bit, T1OSCEN (T1CON<3>). The oscillator is a lowpower circuit rated for 32kHz crystals. It will continue to run during all power-managed modes. The circuit for a typical LP oscillator is shown in Figure12-3. Table12-1 shows the capacitor selection for the Timer1 oscillator. The user must provide a software time delay to ensure proper start-up of the Timer1 oscillator.

timer1 as oscillator


  • Created, Edited and Notes by Prof. Sujit Wagh, SKNCOE, Pune
  • WikiNote Foundation

Last modified: Tuesday, 17 September 2019, 12:43 PM