Specifications
60
3706C–MICRO–2/11
AT89LP3240/6440
12. Enhanced Timer 2
The AT89LP3240/6440 includes a 16-bit Timer/Counter 2 with the following features:
•16-bit timer/counter with one 16-bit reload/capture register
• One external reload/capture input
• Up/Down counting mode with external direction control
•UART baud rate generation
•Output-pin toggle on timer overflow
•Dual slope symmetric operating modes
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter. The
type of operation is s
elected by bit C/T2 in the SFR T2CON. Timer 2 has three operating modes:
capture, auto-reload (up or down counting), and baud rate generator. The modes are selected
by bits in T2CON and T2MOD, as shown in Table 12-3. Timer 2 also serves as the time base for
the Compare/Capture Array (See Section 13. “Compare/Capture Array” on page 69).
Timer 2 consists of two 8-bit register
s, TH2 and TL2. In the Timer function, the register is incre-
mented every clock cycle. Since a clock cycle consists of one oscillator period, the count rate is
equal to the oscillator frequency. The timer rate can be prescaled by a value between 1 and 16
using the Timer Presca ler (see Table 6-2 on page 33).
In the Counter function, the register is incremented in response to a 1-to-0 transition at its corre-
sponding externa
l input pin, T2. In this function, the external input is sampled every clock cycle.
When the samples show a high in one cycle and a low in the next cycle, the count is incre-
mented. The new count value appears in the register during the cycle following the one in which
the transition was detected. Since two clock cycles are requ ired to recognize a 1-to-0 transition,
the maximum cou nt rate is 1/2 of the oscillator frequency. To ensure that a given level is sam-
pled at leas
t once before it changes, the level should be held for at least one full clock cycle.
The following definitions for Timer 2 are used in the subsequent paragraphs:
Table 12-1. Timer 2 Operating Modes
RCLK + TCLK CP/RL2 DCEN T2OE TR2 MODE
0000116-bit Auto-reload
0010116-bit Auto-reload Up-Down
01X0116-bit Capture
1 XXX1Baud Rate Generator
XXX11Frequency Generator
X X X X 0 (Off)
Table 12-2. Timer 2 Definitions
Symbol Definition
MIN 0000H
MAX FFFFH
BOTTOM 16-bit value of {RCAP2H,RCAP2L} (standard modes)
TOP 16-bit value of {RCAP2H,RCAP2L} (enhanced modes)