GD32W51x User Manual
472
TIMER2 is configured as a prescaler for TIMER0. Refer to
master/slave mode example for connections
. Steps are shown as follows:
1.
Configure TIMER2 in master mode and select its update event (UPE) as trigger output
(MMC=3’b010 in the TIMER2_CTL1 register). Then TIMER2 drives a periodic signal on
each counter overflow.
2.
Configure TIMER2 period (TIMER2_CAR register).
3.
Select TIMER2 as TIMER0 input trigger source (TRGS=3’b010 in the TIMERx_SMCFG
register).
4.
Configure TIMER0 in external clock mode 0 (SMC=3’b111 in TIMERx_SMCFG register).
5.
Start TIMER0 by writing ‘1’ to the CEN bit (TIMER0_CTL0 register).
6.
Start TIMER2 by writing ‘1’ to the CEN bit (TIMER2_CTL0 register).
Start TIMER0 with TIMER2’s enable/update signal
First, enable TIMER0 with the enable signal of TIMER2. Refer to
of TIMER0 controlled by enable signal of TIMER2
. TIMER0 starts counting from its current
value with the divided internal clock after being triggered by TIMER2 enable signal output.
When TIMER0 receives the trigger signal, its CEN bit is set automatically and the counter
counts until TIMER0 is disabled. Both clock frequency of the counters are divided by 3 from
TIMER_CK (f
PSC_CLK
= f
TIMER_CK
/3). Steps are shown as follows:
1.
Configure TIMER2 in master mode to send its enable signal as trigger output
(MMC=3’b001 in the TIMER2_CTL1 register).
2.
Select TIMER2 as TIMER0 input trigger source (TRGS=3’b010 in the TIMERx_SMCFG
register).
3.
Configure TIMER0 in event mode (SMC=3’b 110 in TIMERx_SMCFG register).
4.
Start TIMER2 by writing 1 to the CEN bit (TIMER2_CTL0 register).
Figure 17-29. Trigger mode of TIMER0 controlled by enable signal of TIMER2
TIMER_CK
CNT_REG
CNT_REG
CEN
61
62
63
11
12
13
TRGIF
14
TIMER2
TIMER0
In this example, the update event can also be used as trigger source instead of enable signal.
Figure 17-30. Trigger mode of TIMER0 controlled by update signal of TIMER2
Steps are shown as follows: