![GigaDevice Semiconductor GD32E23 Series Скачать руководство пользователя страница 259](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794259.webp)
GD32E23x User Manual
259
Figure 14-28. TIMER0 Master/Slave mode timer example
TIMER0
TIMER 14
Pre scaler
Counter
Master
mode
control
TIMER 2
Pre scaler
Counter
Master
mode
control
Trigger
selection
ITI0
ITI2
CI0F_ED
CI0FE0
CI1FE1
ETIFP
TRGS
TRG O
TRG O
Other interconnection examples:
TIMER2 as prescaler for TIMER0
We configure TIMER2 as a prescaler for TIMER0. Refer to
Master/Slave mode timer example
for connections. Do as follow:
1. Configure TIMER2 in master mode and select its Update Event (UPE) as trigger output
(MMC=010 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=010 in the
TIMER0_SMCFG register).
4. Configure TIMER0 in external clock mode 1 (SMC=111 in TIMER0_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