358
/
838
Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
Setting TIM2_SMCTRL.TSEL = ‘000’ to connect TIM1 trigger output to TIM2.
Setting TIM2_SMCTRL.SMSEL= ‘101’ to set TIM2 to gated mode.
Setting TIM2_CTRL1.CNTEN= ‘1’ to start TIM2.
Setting TIM1_CTRL1.CNTEN= ‘1’ to start TIM1.
Note:
The TIM2 clock is not synchronized with the TIM1 clock, this mode only affects the TIM2 counter enable signal.
Figure 12-23 TIM2 gated by OC1REF of TIM1
In the next example, Gated TIM2 with enable signal of TIM1, Setting TIM1.CTRL1.CNTEN = ‘0’ to stop TIM1. TIM2
counts on the divided
internal clock only when TIM1 is enable. Both counters are clocked based on CK_INT via a
prescaler divide by 3 is performed (f
CK_CNT
= f
CK_INT
/3).
The configuration steps are shown as below
Setting TIM1_CTRL2.MMSEL=’ 001’ to use the enable signal of TIM1 as trigger output
Setting TIM2_SMCTRL.TSEL = ‘000’ to configure TIM2 to get the trigger input from TIM1
Setting TIM2_SMCTRL.SMSEL = ‘101’ to configure TIM2 in gated mode.
Setting TIM2_CTRL1.CNTEN= ‘1’ to start TIM2.
Setting TIM1_CTRL1.CNTEN= ‘1’ to start TIM1.
Setting TIM1_CTRL1.CNTEN= ‘0’ to stop TIM1.
CK_INT
OC1REF
CNT
TITF
63
64
65
00
01
85
86
87
88
CNT
Clear TIF = 0
66
TIM1
TIM2