Datasheet
2009-2011 Microchip Technology Inc. DS39960D-page 197
PIC18F87K22 FAMILY
14.0 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 SOSC oscillator internal options
• Interrupt-on-overflow
• Reset on ECCP Special Event Trigger
• Timer with gated control
Figure 14-1 displays a simplified block diagram of the
Timer1 module.
The Timer1 oscillator can also be used as a low-power
clock source for the microcontroller in power-managed
operation. The Timer1 can also work on the SOSC
oscillator.
Timer1 is controlled through the T1CON Control
register (Register 14-1). It also contains the Secondary
Oscillator Enable bit (SOSCEN). Timer1 can be
enabled or disabled by setting or clearing control bit,
TMR1ON (T1CON<0>).
The F
OSC clock source should not be used with the
ECCP capture/compare features. If the timer will be
used with the capture or compare features, always
select one of the other timer clocking options.
REGISTER 14-1: T1CON: TIMER1 CONTROL REGISTER
R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
TMR1CS1 TMR1CS0 T1CKPS1 T1CKPS0 SOSCEN T1SYNC
RD16 TMR1ON
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-6 TMR1CS<1:0>: Timer1 Clock Source Select bits
10 = Timer1 clock source is either from a pin or oscillator, depending on the SOSCEN bit:
SOSCEN =
0:
External clock from the T1CKI pin (on the rising edge).
SOSCEN =
1:
Depending on the SOSCSEL Configuration bit, the clock source is either a crystal oscillator on the
SOSCI/SOSCO pins or an internal clock from the SCLKI pin.
01 = Timer1 clock source is the system clock (F
OSC)
(1)
00 = Timer1 clock source is the instruction clock (FOSC/4)
bit 5-4 T1CKPS<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
bit 3 SOSCEN: SOSC Oscillator Enable bit
1 = SOSC is enabled and available for Timer1
0 = SOSC is disabled for Timer1
The oscillator inverter and feedback resistor are turned off to eliminate power drain.
bit 2 T1SYNC
: Timer1 External Clock Input Synchronization Select bit
TMR1CS<1:0> =
10:
1 = Do not synchronize external clock input
0 = Synchronize external clock input
TMR1CS<1:0> =
0x:
This bit is ignored. Timer1 uses the internal clock when TMR1CS<1:0> = 1x.
bit 1 RD16: 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
bit 0 TMR1ON: Timer1 On bit
1 = Enables Timer1
0 =Stops Timer1
Note 1: The F
OSC clock source should not be selected if the timer will be used with the ECCP capture/compare features.