BAT32G1x9 user manual | Chapter 6 Universal timer unit Timer4/8
205 / 1149
Rev.1.02
Fig. 6-56 input signal when measuring the high and low level width function
software operation
hardware state
Timer Unit 0 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).
Set T0Emn bit to '0', and stop T0mn operation.
channel in operation stopped state (providing clock,
consume portion of power)
set TSmn bit to '1'.
Because TSmn bit is trigger bit, thus automatically return to
'0'.
TEmn bit turns into '1' and enter into start trigger (detect
Timn pin input valid edge or set TSmn bit to '1') detection
waiting state.
detect TImn pin input counting start edge
clear timer counting register mn (TCRmn) to '0000H" and
start decremental counting.
in operation
can modify any TDRmn register configuration value.
Can read TCRmn register anytime.
Do not use TSRmn register.
Forbidden modifying TMRmn register,
TOMmn bit and TOLmn bit,Tomn and T0Emn bit
configuration value.
while detecting TImn pin start edge, Counter(TCRmn) start
incremental counting from "0000H", if detecting TImn pin
input capture edge, then transfer counting value to Timer
data register mn(TDRmn) 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.
TCRmn register stop counting before detecting next TImn
pin start edge.
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
Start operation
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).