
GD32L23x User Manual
314
Enable TIMER1
count with TIMER2’s enable/O0CPRE signal
In this example, we control the enable of TIMER1 with the enable output of TIMER2 .Refer to
Figure 17-23. Pause TIMER1 with enable of TIMER2
TIMER1 counts on the divided internal
clock only when TIMER2 is enable. Both counter clock frequencies are divided by 3 by the
prescaler compared to TIMER_CK (f
CNT_CLK
= f
TIMER_CK
/3). Do as follow:
1. Configure TIMER2 input master mode and output enable signal as trigger output
(MMC=001 in the TIMER2_CTL1 register).
2. Configure TIMER1 to get the input trigger from TIMER2 (TRGS=000 in the
TIMER1_SMCFG register).
3. Configure TIMER1 in pause mode (SMC=101 in TIMER1_SMCFG register).
4. Enable TIMER1
by writing ‘1 in the CEN bit (TIMER1_CTL0 register)
5.
Start TIMER2 by writing ‘1 in the CEN bit (TIMER2_CTL0 register).
6.
Stop TIMER2 by writing ‘0 in the CEN bit (TIMER2_CTL0 register).
Figure 17-23. Pause TIMER1 with enable of TIMER2
TIMER_CK
CNT_REG
CNT_REG
CEN
61
62
63
11
12
13
TRGIF
TIMER2
TIMER1
In this example, we also can use O0CPRE as trigger source instead of enable signal output.
Refer to
Figure 17-24. Pause TIMER1 with O0CPREof TIMER2
.Do as follow:
1. Configure TIMER2 in master mode and output compare 0 Reference (O0CPRE) signal
as trigger output (MMS=100 in the TIMER2_CTL1 register).
2. Configure the TIMER2 O0CPRE waveform (TIMER2_ CHCTL0 register).
3. Configure TIMER1 to get the input trigger from TIMER2 (TRGS=000 in the
TIMER1_SMCFG register).
4. Configure TIMER1 in pause mode (SMC=101 in TIMER1_SMCFG register).
5. Enable TIMER1 by w
riting ‘1 in the CEN bit (TIMER1_CTL0 register).
6. Start
TIMER2 by writing ‘1 in the CEN bit (TIMER2_CTL0 register).