BAT32G1x9 user manual | Chapter 6 Universal timer unit Timer4/8
201 / 1149
Rev.1.02
Fig. 6-53 Operation steps when the pulse interval measurement function is input
software operation
hardware state
Timer Unit m input clock is in stopped state (stop
providing clock, not able to write into registers)
set TM4mEN bit of peripheral enable register 0
(PER0) to '1'
Timer Unit m input clock is in active state, all channels
in operation stopped state.
configure Timer clock selection register
m(TPSm), confirm CKm0~CKm3 clock
frequency
Channel Initial
configuration
set corresponding bit of noise filter enable
register 1 (NFEN1) to '0' (OFF) or '1' (ON).
Configure Timer mode register mn (TMRmn)
(confirm channel operation mode).
channel in operation stopped state (providing clock,
consume portion of power)
Start operation
set TSmn bit to '1'.
Because TSmn bit is trigger bit, thus
automatically return to '0'.
TEmn bit turns into '1' and start counting.
Clear Timer counting register (TCRn) to "0000H".
When MDmn0 bit of TMRmn register is '1', generate
INTTMmn.
in operation
can only modify configure value of CISmn1 bit
and CISmn0 bit of TMRmn register.
Can read TDRmn register anytime.
Can read TCRmn register aanytime.
Can read TSRmn register anytime.
Forbidden modifying TOMmn bit, TOLmn bit,
TOmn bit and TOEmn bit configuration.
Counter(TCRmn) start incremental counting from
"0000H", if detecting TImn pin input valid edge or TSmn
bit set to '1', then transfer (capture) counting value to
Timer data register mn(TDRmn), at the same time,
clear TCRmn to "0000H" and generate INTTmn.
At this time, if overflow occurs, then set OVF bit of
Timer status register mn(TSRmn) . If overflow does not
occur, then clear OVF bit. Thereafter, repeat the
process.
stop operation
set TTmn bit to '1'.
Because TTmn bit is trigger bit, thus
automatically return to '0'.
TEmn bit turns into '0' and stop counting.
TCRmn register hold counted value and stop counting.
0VF bit of TSRmn register remains unchange.
timer 4 stop
set TM4mEN bit of peripheral enable register 0
(PER0) to '1'
Timer Unit m input clock is not been provided.Perform
initialization to all circuit and SFR of all channels.
(TO00 bit turns into '0' and TO00 pin becomes port
function)
Timer 4 initial
configuration
re
s
ta
rt
o
p
e
ra
tio
n
Note: m: Unit number (m=0,1) n: Channel number (when m=0: n=0~3, m=1: n=0~7).