Megawin Technology Co., Ltd.
MG87FE/L52
8.3 Timer2
Timer2 is a 16-bit timer/counter which can operate as either an event timer or an event counter
as selected by C//T2 in the special function register T2CON. Timer2 has four operation modes:
Capture Mode(CP), Auto-Reload Up/Down Mode(ARUD), Auto-Reload Up-Only Mode(ARUO)
and Baud-Rate Generator Mode(BRG).
Table 8-1. Timer-2 Mode Table
Logical OR
CP/RL2
TR2
DCEN
Mode
(RCLK, TCLK)
x
x
x
1
0
0
0
1
1
1
1
x
0
0
0
1
OFF
1
0
0
0
Baud-Rate Generation
Capture
Auto-Reload Up-only
Auto-Reload Up/Down
Timer2 is also can be configured as a periodical signal generator.
The MG87FE/L52 is able to generate a programmable clock output from P1.0. When T2OE bits
is set and C//T2 bits is cleared, Timer2 overflow pulse will generate a 50% duty clock and output
to P1.0. The frequency of clock-out is calculated according to the following formula.
In the clock-out mode, Timer2 overflowed will not generate an interrupt.
Capture Mode (CP)
In the Capture mode, Timer2 is incremented by either CLKin(System Clock) or external pin (T2)
1-to-0 transition. TR2 controls the event to timer2 and a 1-to-0 transition on T2EX pin will trigger
RCAP2H and RCAP2L registers to capture the Timer2 contents onto them if EXEN2 is set. An
overflow in Timer2 set TF2 flag and a 1-to-0 transition in T2EX pin sets EXF2 flag if EXEN2=1.
TF2 and EXF2 is logic OR to request the interrupt service.
20
Preliminary ver 1.3
Date: 2009-JAN-20