BAT32G1x9 user manual | Chapter 6 Universal timer unit Timer4/8
198 / 1149
Rev.1.02
Fig. 6-50 Operational Steps for Frequency Divider (take channel 0 of unit 0 as an example)
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 0 input clock is in active state (start
providing clock, able to write into registers)
configure Timer clock selection register 0 (TPS0),
confirm CK00~CK03 clock frequency
set corresponding bit of noise filter enable register 1
(NFEN1) to '0' (OFF) or '1' (ON).
Configure Timer mode register 00 (TMR00) (confirm
channel operation mode, select edge detection).
Configure interval(period) valule of Timer data register
00 (TDR00)
channel in operation stopped state (providing clock,
consume portion of power)
set TOM00 bit of timer output mode register 0 (TOM0)
to '0' (master control channel output mode).
Set TOL00 bit to '0'
configure TO00 bit and confirm TO00 output initial
voltage value.
Set TOE00 bit to '1', aloow TO00 output.
Set port register and port mode register to '0'.
TO00 pin in Hi-Z output state.
When port mode register set to output mode and
port register as '0', output TO00 initial configured
voltage level.
Because channel is in operation stopped state,
thus TO00 remains unchange. TO00 pin output
TO00 configured voltage level.
Start operation
set TOE00 bit to '1' (only limited to restart operation).
Set TS00 bit to '1'.
Because TS00 bit is trigger bit, thus automatically
return to '0'.
TE00 bit turns to '1' and start counting.
Load TDR00 register value into Timer count register
00 (TCR00). When MD000 bit of TMR00 register
turns into '1', generate INTTM00 and TO00 swaps
output
in operation
can modify any TDR00 register configuration value.
Can read TCR00 register anytime.
Do not use TSR00 register.
Can modify TO0 register and TOE0 register value.
Forbidden modifying TMR00 register.
TOM00 bit and TOL00 bit configuration value.
Counter (TCR00) performs decremental counting.
When count reaches '0000H', then load TDR00
register value into TCR00 register again and
continue counting. When detecting TCR00 as
'0000H', generate INTTM00 and TO00 swaps output.
Thereafter, repeat the operation.
set TT00 bit to '1'.
Because TT00 bit is trigger bit, thus automtically
return to '0'.
TE00 bit turns to '0' and stop counting.
TCR00 register remains counted value and stop
counting.
TO00 output not been initialized and remain same
state.
TO00 pin outputs TO00 configured voltage.
set TOE00 bit to '0' and configure value for TO00 bit.
TO00 pin output TO00 configured voltage level.
Scenarios to maintain TO00 pin output voltage:
set TO00 bit to '0' after set hold value to port register
configuration.
In case TO00 pin output voltage does not need to be
held: no configuration requried
hold TO00 pin output voltage level via port function.
set TM4mEN bit of peripheral enable register 0
(PER0) to '0'
Timer Unit 0 input clock is in stopped state.
Perform initialization to all circuit and SFR of all
channels.
(TO00 bit turns into '0' and TO00 pin becomes port
function)
Timer 4 stop
Timer 4 initial
configuration
Channel Initial
configuration
stop operation
R
e
s
ta
rt
o
p
e
ra
tio
n