BAT32G1x9 user manual | Chapter 6 Universal timer unit Timer4/8
193 / 1149
Rev.1.02
3
2
3
1
2
1
2
1
2
0
0
0
1
0003H
0002H
6.8.2
Run as an external event counter
It can be used as an event counter to count the effective edges (external events) of the detected TImn pin input
and generate an interrupt if the specified count value is reached. The specified count value can be calculated using
the following calculation:
In event counter mode, the timer count register mn (TCRmn) is used as a decrement counter.
By setting any channel start trigger bit (TSmn, TSHm1, TSHm3) of the timer channel start register m (TSm),
"1", Load the value of the timer data register mn (TDRmn) into the TCRmn register.
The TCRmn register counts down while detecting a valid edge of the input of the TImn pin. If TCRmn becomes
"0000H", the value of the TDRmn register is loaded again and intTMmn is output.
After that, the same run continues.
Because the TOmn pin outputs an irregular waveform based on an external event, the timer output must be "0"
at the TOEmn position of the enable register m (TOEm) to stop the output.
The TDRmn register can be overwritten at any time, and the value of the rewritten TDRmn register is valid for
the next count period.
Figure 6-45 serves as a basic timing example of an external event counter operation
TSmn
TEmn
TImn
TCRmn
TDRmn
INTTMmn
Note: 1. m
: unit number (m=0,1)n: channel number (when m=0: n=0~3, m=1: n=0~7).
2. TSmn : The bitn of the timer channel start register m(TSm).
TEmn : The timer channel enable bitn of the status register m(TEm).
TImn : The TImn pin input signal
TCRmn: Timer count register mn (TCRmn).
TDRmn: Timer data register mn (TDRmn).
The specified
count
value
= TD
Rmn's
set
value
+1