mg84fl54 Megawin Technology, mg84fl54 Datasheet - Page 35

no-image

mg84fl54

Manufacturer Part Number
mg84fl54
Description
Full-speed Usb Micro-controller
Manufacturer
Megawin Technology
Datasheet
11.2. Timer 2
Timer 2 is a 16-bit Timer/Counter which can operate either as a timer or an event counter, as selected by C/-T2
in T2CON register. Timer 2 has four operating modes: Capture, Auto-Reload (up or down counting), Baud Rate
Generator and Programmable Clock-Out, which are selected by bits in the T2CON and T2MOD registers.
11.2.1. Capture Mode (CP)
In the capture mode there are two options selected by bit EXEN2 in T2CON. If EXEN2=0, Timer 2 is a 16-bit
timer or counter which, upon overflow, sets bit TF2 (Timer 2 overflow flag). This bit can then be used to
generate an interrupt (by enabling the Timer 2 interrupt bit in the IE register). If EXEN2=1, Timer 2 still does the
above, but with the added feature that a 1-to-0 transition at external input T2EX causes the current value in the
Timer 2 registers, TH2 and TL2, to be captured into registers RCAP2H and RCAP2L, respectively. In addition,
the transition at T2EX causes bit EXF2 in T2CON to be set, and the EXF2 bit (like TF2) can generate an
interrupt which vectors to the same location as Timer 2 overflow interrupt. The capture mode is illustrated in Fig
11-5.
Fig 11-5 Timer 2 in Capture Mode
MEGAWIN
SYSCLK
SYSCLK
12
T2EX Pin
T2 Pin
AUXR.T2X12=1
AUXR.T2X12=0
Transition
Detection
C//T2=0
C//T2=1
EXEN2
TR2
MG84FL54B Data sheet
Capture
RCAP2L
(8 Bits)
TL2
RCAP2H
(8 Bits)
TH2
Overflow
EXF2
TF2
Timer2 Interrupt
35

Related parts for mg84fl54