English
Language : 

MG82FX532AE Datasheet, PDF (55/151 Pages) Megawin Technology Co., Ltd – Dual data pointer
11.2.2. Auto-Reload Mode (AR) Structure
Figure 11-6 shows DCEN=0, which enables Timer 2 to count up automatically. In this mode there are two options
selected by bit EXEN2 in T2CON register. If EXEN2=0, then Timer 2 counts up to 0FFFFH and sets the TF2
(Overflow Flag) bit upon overflow. This causes the Timer 2 registers to be reloaded with the 16-bit value in
RCAP2L and RCAP2H. The values in RCAP2L and RCAP2H are preset by firmware. If EXEN2=1, then a 16-bit
reload can be triggered either by an overflow or by a 1-to-0 transition at input T2EX. This transition also sets the
EXF2 bit. The Timer 2 interrupt, if enabled, can be generated when either TF2 or EXF2 are 1.
Figure 11-6 Timer 2 in Auto-Reload Mode (DCEN=0)
SYSCLK
¸ 12
T2MOD.T2X12=0
SYSCLK
T2MOD.T2X12=1 C/T2=0
T2 Pin
C/T2=1
TL2
(8 Bits)
TR2 Reload
Overflow
TH2
(8 Bits)
TF2
T2EX Pin
Transition
Detection
RCAP2L RCAP2H
EXF2
Timer2 Interrupt
EXEN2
Fig 11-7 shows DCEN=1, which enables Timer 2 to count up or down. This mode allows pin T2EX to control the
counting direction. When a logic 1 is applied at pin T2EX, Timer 2 will count up. Timer 2 will overflow at 0FFFFH
and set the TF2 flag, which can then generate an interrupt if the interrupt is enabled. This overflow also causes
the 16-bit value in RCAP2L and RCAP2H to be reloaded into the timer registers TL2 and TH2. A logic 0 applied
to pin T2EX causes Timer 2 to count down. The timer will underflow when TL2 and TH2 become equal to the
value stored in RCAP2L and RCAP2H. This underflow sets the TF2 flag and causes 0FFFFH to be reloaded into
the timer registers TL2 and TH2.
The external flag EXF2 toggles when Timer 2 underflows or overflows. This EXF2 bit can be used as a 17th bit of
resolution if needed. The EXF2 flag does not generate an interrupt in this mode.
Fig 11-7 Timer 2 in Auto-Reload Mode (DCEN=1)
(Down Counting Reload Value)
FFH
FFH
Toggle
EXF2
SYSCLK
¸ 12
T2MOD.T2X12=0
SYSCLK
T2MOD.T2X12=1 C/T2=0
T2 Pin
C/T2=1
TR2
TL2
(8 Bits)
TH2
(8 Bits)
Overflow
Timer2 Interrupt
TF2
RCAP2L RCAP2H
Count Direction
1 = UP
0 = DOWN
(Up Counting Reload Value)
T2EX Pin
MEGAWIN
MG82FE/L532 Data Sheet
55