mg84fl54 Megawin Technology, mg84fl54 Datasheet - Page 36

no-image

mg84fl54

Manufacturer Part Number
mg84fl54
Description
Full-speed Usb Micro-controller
Manufacturer
Megawin Technology
Datasheet
11.2.2. Auto-Reload Mode (AR)
Fig 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.
Fig 11-6 Timer 2 in Auto-Reload Mode (DCEN=0)
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)
36
SYSCLK
SYSCLK
SYSCLK
SYSCLK
12
12
T2EX Pin
T2 Pin
T2 Pin
AUXR.T2X12=0
AUXR.T2X12=1
AUXR.T2X12=1
AUXR.T2X12=0
Transition
Detection
C//T2=0
C//T2=1
C//T2=0
C//T2=1
TR2
MG84FL54B Data Sheet
EXEN2
TR2
Reload
(Down Counting Reload Value)
(Up Counting Reload Value)
RCAP2L
(8 Bits)
FFH
TL2
RCAP2L
(8 Bits)
TL2
RCAP2H
(8 Bits)
FFH
TH2
RCAP2H
(8 Bits)
TH2
Overflow
Overflow
T2EX Pin
EXF2
TF2
Count Direction
1 = UP
0 = DOWN
Toggle
TF2
Timer2 Interrupt
Timer2 Interrupt
MEGAWIN
EXF2

Related parts for mg84fl54