
The capture / compare units
UM0404
DocID13284 Rev 2
Refer to the device datasheet for a table of timer input frequencies, resolution and periods
for each pre-scaler option in TxI.
After a timer has been started by setting its run flag (TxR) to '1', the first increment will occur
within the time interval which is defined by the selected timer resolution. All further
increments occur exactly after the time defined by the timer resolution.
When both timers of a CAPCOM unit are to be incremented or reloaded at the same time T0
is always serviced one CPU clock before T1, T7 before T8, respectively.
Counter mode
The bit TxM in SFRs T01CON and T78CON select between timer or counter mode for the
respective timer. In Counter mode (TxM = ‘1’) the input clock for a timer can be derived from
the overflows / underflows of timer T6 in block GPT2. In addition, timers T0 and T7 can be
clocked by external events. Either a positive, a negative, or both a positive and a negative
transition at pin T0IN (alternate input function of port pin P3.0) or T7IN (alternate input
function of port pin P2.15), respectively, can be selected to cause an increment of T0 / T7.
When T1 or T8 is programmed to run in counter mode, bit-field TxI is used to enable the
overflows / underflows of timer T6 as the count source. This is the only option for T1 and T8,
and it is selected by the combination TxI = X00b. When bit-field TxI is programmed to any
other combination, the respective timer (T1 or T8) will stop.
When T0 or T7 is programmed to run in counter mode, bit-field TxI is used to select the
count source and transition (if the source is the input pin) which should cause a count trigger
(see description of TxyCON for the possible selections).
Note:
In order to use pin T0IN or T7IN as external count input pin, the respective port pin must be
configured as input, and the corresponding direction control bit (DP3.0 or DP2.15) must be
cleared ('0').
If the respective port pin is configured as output, the associated timer may be clocked by
modifying the port output latches P3.0 or P2.15 via software, for example for testing
purposes.
The maximum external input frequency to T0 or T7 in counter mode is f
CPU
/ 16. To ensure
that a signal transition is properly recognized at the timer input, an external count input
signal should be held for at least eight CPU clock cycles before it changes its level again.
The incremented count value appears in SFR T0 / T7 within eight CPU clock cycles after the
signal transition at pin TxIN.
Reload
A reload of a timer with the 16 bit value stored in its associated reload register in both
modes is performed each time a timer overflows from FFFFh to 0000h. In this case the timer
does not wrap around to 0000h, but rather is reloaded with the contents of the respective
reload register TxREL. The timer then resumes incrementing, from the reloaded value.
Timer input selection TxI
000b
001b
010b
011b
100b
101b
110b
111b
Pre-scaler for f
CPU
8
16
32
64
128
256
512
1024
Resolution in
CPU clock cycles
8
16
32
64
128
256
512
1024