
XC161 Derivatives
Peripheral Units (Vol. 2 of 2)
The General Purpose Timer Units
User’s Manual
14-31
V2.2, 2004-01
GPT_X1, V2.0
14.2
Timer Block GPT2
From a programmer’s point of view, the GPT2 block is represented by a set of SFRs as
summarized below. Those portions of port and direction registers which are used for
alternate functions by the GPT2 block are shaded.
Figure 14-19 SFRs Associated with Timer Block GPT2
Both timers of block GPT2 (T5, T6) can run in one of 3 basic modes: Timer Mode, Gated
Timer Mode, or Counter Mode. All timers can count up or down. Each timer of GPT2 is
controlled by a separate control register TxCON.
Each timer has an input pin TxIN (alternate pin function) associated with it, which serves
as the gate control in gated timer mode, or as the count input in counter mode. The count
direction (up/down) may be programmed via software. An overflow/underflow of core
timer T6 is indicated by the Output Toggle Latch T6OTL, whose state may be output on
the associated pin T6OUT (alternate pin function). The auxiliary timer T5 may
additionally be concatenated with the core timer T6 (through T6OTL).
The Capture/Reload register CAPREL can be used to capture the contents of timer T5,
or to reload timer T6. A special mode facilitates the use of register CAPREL for both
functions at the same time. This mode allows frequency multiplication. The capture
function is triggered by the input pin CAPIN, or by GPT1 timer’s T3 input lines T3IN and
T3EUD. The reload function is triggered by an overflow or underflow of timer T6.
Overflows/underflows of timer T6 may also clock the timers of the CAPCOM units.
The current contents of each timer can be read or modified by the CPU by accessing the
corresponding timer count registers T5 or T6, located in the non-bitaddressable SFR
m c_ g p t0 1 0 2 _ re g iste rs.vsd
D a ta R e g is te rs
C o n tro l R eg isters
P o rt R e gisters
T5
T5C O N
T5IC
T6
T6C O N
T6IC
C A PR EL
C R IC
O D P3
D P3
P3
E
P5
P5D ID IS
A LTSEL0P3
E
In terru pt C o ntro l
SYSC O N 3
T x
G P T 2 T im er x R eg is ter
C A P R E L
G P T 2 C a p tu re /R elo ad R e gister
T xC O N
G P T 2 T im er x C on trol R e gister
T xIC
G P T 2 T im er x Inte rrup t C trl. R eg .
S Y S C O N 3
S yste m C trl. R eg . 3 (P e r. M gm t.)
O D P 3
P o rt 3 O p en D ra in C o ntro l R e g is te r
D P 3
P o rt 3 D irec tio n C on trol R e giste r
P 3
P o rt 3 D a ta R eg is te r
A L T S E L 0P 3 P o rt 3 A ltern ate O utpu t S ele ct R e g.
P 5
P o rt 5 D a ta R eg is te r
P 5 D ID IS
P o rt 5 D ig ital Inp ut D isa b le R e g.