Advanced-control timers (TIM1)
RM0365
475/1080
DocID025202 Rev 7
Figure 155. TI2 external clock connection example
For example, to configure the upcounter to count in response to a rising edge on the TI2
input, use the following procedure:
1.
Configure channel 2 to detect rising edges on the TI2 input by writing CC2S = ‘01’ in
the TIMx_CCMR1 register.
2. Configure the input filter duration by writing the IC2F[3:0] bits in the TIMx_CCMR1
register (if no filter is needed, keep IC2F=0000).
3. Select rising edge polarity by writing CC2P=0 and CC2NP=0 in the TIMx_CCER
register.
4. Configure the timer in external clock mode 1 by writing SMS=111 in the TIMx_SMCR
register.
5. Select TI2 as the trigger input source by writing TS=110 in the TIMx_SMCR register.
6. Enable the counter by writing CEN=1 in the TIMx_CR1 register.
Note:
The capture prescaler is not used for triggering, so the user does not need to configure it.
When a rising edge occurs on TI2, the counter counts once and the TIF flag is set.
The delay between the rising edge on TI2 and the actual clock of the counter is due to the
resynchronization circuit on TI2 input.
([WHUQDOFORFN
PRGH
,QWHUQDOFORFN
PRGH
75*,
&.B,17
&.B36&
7,0[B60&5
606>@
,75[
7,B('
7,)3
7,)3
7,0[B60&5
76>@
7,
7,0[B&&(5
&&3
)LOWHU
,&)>@
7,0[B&&05
(GJH
GHWHFWRU
7,)B5LVLQJ
7,)B)DOOLQJ
[[
069
LQWHUQDOFORFN
7,)
RU
7,)
RU
RU
(QFRGHU
PRGH
(75)
([WHUQDOFORFN
PRGH
(75)
(&(