GD32VF103 User Manual
250
2. Configure the Timer2 period (TIMER2_CARL registers).
3. Configure TIMER0 to get the input trigger from Timer2 (TRGS=
3’b010 in the
TIMER0_SMCFG register).
4. Configure TIMER0 in event
mode (SMC=3’b110 in TIMERx_SMCFG register).
5. Start TIMER
2 by writing ‘1 in the CEN bit (TIMER2_CTL0 register).
Figure 15-30. Triggering TIMER0 with update signal of TIMER2
TIMER_CK
TIMER2_CNT_REG
TIMER0_CNT_REG
TIMER2_UPE
62
11
12
TIMER0_TRGIF
63
00
01
02
TIMER0_CEN
13
14
Enable TIMER0 count with TIMER
2’s enable/O0CPRE signal
In this example, we control the enable of TIMER0 with the enable output of TIMER2 .Refer to
Figure 15-31. Pause TIMER0 with enable signal of TIMER2
. TIMER0 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=
3’b001 in the TIMER2_CTL1 register).
2. Configure TIMER0 to get the input trigger from TIMER2 (TRGS=
3’b010 in the
TIMER0_SMCFG register).
3. Configure TIMER0 in pause mode (SMC=
3’b101 in TIMERx_SMCFG register).
4. Enable TIMER
0 by writing ‘1 in the CEN bit (TIMER0_CTL0 register)
5. Start TIMER
2 by writing ‘1 in the CEN bit (TIMER2_CTL0 register).
6. Stop TIMER
2 by writing ‘0 in the CEN bit (TIMER2_CTL0 register).