GD32F10x User Manual
295
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 the Timer2 period (TIMER2_CAR registers).
3.
Select the Timer0 input trigger source from Timer2 (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 in the CEN bit (TIMER0_CTL0 register).
6.
Start Timer2 by writing ‘1 in the CEN bit (TIMER2_CTL0 register).
Start Timer0 with Timer2’s Enable/Update signal
In this example, we enable Timer0 with the enable output of Timer2. Refer to
Triggering TIMER0 with enable signal of TIMER2
. Timer0 starts counting from its current
value on the divided internal clock after trigger by Timer2 enable output.
When Timer0 receives the trigger signal, its CEN bit is set and the counter counts until we
disable timer0. In this example, both counter clock frequencies are divided by 3 by the
prescaler compared to TIMER_CK
(f
CNT_CLK
= f
TIMER_CK
/3). Timer0’s SMC is set as event mode,
so Timer0 can not be disabled by Timer2’s disable signal. Do as follow:
1. Configure Timer
2 master mode to send its enable signal as trigger output(MMC=3’b001
in the TIMER2_C
TL1 register)
2. Configure Timer0 to select the input trigger from Timer2 (TRGS
=3’b010 in the
TIMERx_SMCFG register).
3. Configure Timer0 in event mo
de (SMC=3’b 110 in TIMERx_SMCFG register).
4. Start Timer2 by writing 1 in the CEN bit (TIMER2_CTL0 register).
Figure 15-29. Triggering TIMER0 with enable signal of TIMER2
TIMER_CK
CNT_REG
CNT_REG
CEN
61
62
63
11
12
13
TRGIF
14
TIMER2
TIMER0
Using an external trigger to start 2 timers synchronously
We configure the start of Timer0 triggered by the enable signal of Timer2, and Timer2 is
Summary of Contents for GD32F10 Series
Page 63: ...GD32F10x User Manual 63 programmed during the chip production ...
Page 117: ...GD32F10x User Manual 117 010 1 0 011 0 9 ...
Page 416: ...GD32F10x User Manual 416 shadow register updates every update event ...
Page 427: ...GD32F10x User Manual 427 value ...
Page 518: ...GD32F10x User Manual 518 These bits are not used in SPI mode ...