C165
Data Sheet 20 V2.0, 2000-12
General Purpose Timer (GPT) Unit
The GPT unit represents a very flexible multifunctional timer/counter structure which
may be used for many different time related tasks such as event timing and counting,
pulse width and duty cycle measurements, pulse generation, or pulse multiplication.
The GPT unit incorporates five 16-bit timers which are organized in two separate
modules, GPT1 and G PT2. Eac h time r in eac h mod ule may op erate inde pend ently in a
number of different modes, or may be concatenated with another timer of the same
module.
Each of the three timers T2 , T3, T4 o f module GP T1 c an be c onfigu red i ndivi duall y for
one of four basic modes of operation, which are Timer, Gated Timer, Counter, and
Incremental Interface Mode. In Timer Mode, the input clock for a timer is derived from
the CPU clock, divided by a programmable prescaler, while Counter Mode allows a timer
to be clocked in reference to external events.
Pulse width or duty cycle measurement is supported in Gated Timer Mode, where the
operation of a timer is controlled by the ‘gate’ level on an external input pin. For these
purpose s, each t imer has o ne a ssocia ted p ort pin (TxIN ) whic h serves as gate or clock
input. The maximum resolution of the timers in module GPT1 is 16 TCL.
The count direction (up/down) for each timer is programmable by software or may
additionally be altered dynamically by an external signal on a port pin (TxEUD) to
facilitate e.g. position tracking.
In Increme ntal Interface Mod e the GPT1 timers (T2, T3, T4 ) can be dire ctly connected
to the i ncremental p osition se nsor signal s A and B via their respec tive input s TxIN and
TxEUD. Directi on and cou nt signa ls are internally derived from these two in put signa ls,
so the contents of the respective ti mer Tx co rresp onds to the sensor p osi tion . The third
position sensor signal TOP0 can be connected to an interrupt input.
Timer T3 has an output toggle latch (T3OTL) which changes its state on each timer over-
flow/underflow. The state of this latch may be output on pin T3OUT e.g. for time out
monitoring of ex ternal hardwa re components , or may be used in ternally to clo ck timers
T2 and T4 for measuring long time periods with high resolution.
In addition to their basic operating modes, timers T2 and T4 may be configured as reload
or capture registers for timer T3. When used as capture or reload registers, timers T2
and T4 are stopped. The contents of timer T3 is captured into T2 or T4 in response to a
signal at their associated input pins (TxIN). Timer T3 is reloaded with the contents of T2
or T4 triggered either by an external signal or by a selectable state transition of its toggle
latch T3OTL. When bot h T2 a nd T4 are con figu r ed to alte rnately re loa d T3 on o pposite
state trans itions of T3OT L with the low and hig h tim es of a PWM sign al, th is signa l can
be constantly generated without software intervention.