GD32W51x User Manual
473
1.
Configure TIMER2 in master mode to send its update event (UPE) as trigger output
(MMC=3’b010 in the TIMER2_CTL1 register).
2.
Configure the TIMER2 period (TIMER2_CARL registers).
3.
Select TIMER2 as TIMER0 input trigger source (TRGS=3’b010 in the TIMERx_SMCFG
register).
4.
Configure TIMER0 in event mode (SMC=3’b110 in TIMERx_SMCFG register).
5.
Start TIMER2 by writing ‘1’ to the CEN bit (TIMER2_CTL0 register).
Figure 17-30. Trigger mode of TIMER0 controlled by update signal of TIMER2
TIMER_CK
CNT_REG
CNT_REG
UPE
62
11
12
TRGIF
63
00
01
02
CEN
13
14
TIMER0
TIMER2
Enable TIMER0 to count with the enable/O0CPRE signal of TIMER2.
In this example, TIMER0 is enabled with the enable signal of TIMER2. Refer to
Pause mode of TIMER0 controlled by enable signal of TIMER2
TIMER0 counts with the
divided internal clock only when TIMER2 is enabled. 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 and output 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 pause mode (SMC=3’b101 in TIMERx_SMCFG register).
4.
Enable TIMER0 by writing ‘1’ to the CEN bit (TIMER0_CTL0 register).
5.
Start TIMER2 by writing ‘1’ to the CEN bit (TIMER2_CTL0 register).
6.
Stop TIMER2 by writing ‘0’ to the CEN bit (TIMER2_CTL0 register).