
DocID13284 Rev 2
243/564
UM0404
The general purpose timer units
Figure 97. GPT2 register CAPREL in reload mode
GPT2 capture / reload register CAPREL in capture-and-reload mode
Since the reload function and the capture function of register CAPREL can be enabled
individually by bit T5SC and T6SR, the two functions can be enabled simultaneously by
setting both bits. This feature can be used to generate an output frequency that is a multiple
of the input frequency (see
).
This combined mode can be used to detect consecutive external events which may occur
periodically, but where a finer resolution, that means, more 'ticks' within the time between
two external events is required.
For this purpose, the time between the external events is measured using timer T5 and the
CAPREL register.
For example, Timer T5 runs in timer mode counting up with a frequency of f
CPU
/ 32. The
external events are applied to pin CAPIN. When an external event occurs, the timer T5
contents are latched into register CAPREL, and timer T5 is cleared (T5CLR = ‘1’).
Thus, register CAPREL always contains the correct time between two events, measured in
timer T5 increments. Timer T6, which runs in timer mode counting down with a frequency of
f
CPU
/ 4, uses the value in register CAPREL to perform a reload on underflow. This means,
the value in register CAPREL represents the time between two underflows of timer T6, now
measured in timer T6 increments. Since timer T6 runs eight times faster than timer T5, it will
underflow eight times within the time between two external events.
Thus, the underflow signal of timer T6 generates eight 'ticks'. Upon each underflow, the
interrupt request flag T6IR will be set and bit T6OTL will be toggled. The state of T6OTL
may be output on pin T6OUT. This signal has eight times more transitions than the signal
which is applied to pin CAPIN.
The underflow signal of timer T6 can furthermore be used to clock one or more of the timers
of the CAPCOM units, which gives the user the possibility to set compare events based on a
finer resolution than that of the external events.
T6SR
CAPREL Register
T6OTL
Interrupt
Core Timer T6
Up/Down
Input
Clock
T6IR
T6OE
To CAPCOM
T6OUT
P3.1
Request
Timers