Figure 140. Ti2 External Clock Connection Example; Figure 141. Control Circuit In External Clock Mode 1 - ST STM32F40 Series Reference Manual

Hide thumbs Also See for STM32F40 Series:
Table of Contents

Advertisement

General-purpose timers (TIM2 to TIM5)

Figure 140. 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).
Note:
The capture prescaler is not used for triggering, so you don't need to configure it.
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 input source by writing TS=110 in the TIMx_SMCR register.
6.
Enable the counter by writing CEN=1 in the TIMx_CR1 register.
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.

Figure 141. Control circuit in external clock mode 1

External clock source mode 2
This mode is selected by writing ECE=1 in the TIMx_SMCR register.
435/1422
TI2
Edge
Filter
Detector
TI2F_Falling
ICF[3:0]
TIMx_CCMR1
CNT_EN
Counter clock = CK_CNT = CK_PSC
Counter register
Doc ID 018909 Rev 4
TIMx_SMCR
TS[2:0]
ITRx
001
TI1F_ED
100
TI1FP1
101
TI2F_Rising
0
TI2FP2
110
1
ETRF
111
CC2P
TIMx_CCER
TI2
34
TIF
Write TIF=0
TI2F
or
or
TI1F
or
encoder
mode
external clock
TRGI
mode 1
ETRF
external clock
mode 2
CK_INT
internal clock
mode
(internal clock)
ECE
SMS[2:0]
TIMx_SMCR
35
RM0090
CK_PSC
36

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32F40 Series and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Stm32f41 seriesStm32f42 seriesStm32f43 seriesRm0090

Table of Contents

Save PDF