29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

RM0008<br />

General-purpose timer (TIMx)<br />

The delay between the rising edge on TI2 <strong>and</strong> the actual clock of the counter is due to the<br />

resynchronization circuit on TI2 input.<br />

Figure 121. Control circuit in external clock mode 1<br />

TI2<br />

CNT_EN<br />

Counter clock = CK_CNT = CK_PSC<br />

Counter register 34<br />

35 36<br />

TIF<br />

Write TIF=0<br />

External clock source mode 2<br />

This mode is selected by writing ECE=1 in the TIMx_SMCR register.<br />

The counter can count at each rising or falling edge on the external trigger input ETR.<br />

The Figure 122 gives an overview of the external trigger input block.<br />

Figure 122. External trigger input block<br />

TI2F<br />

or<br />

TI1F<br />

or<br />

or<br />

encoder<br />

mode<br />

ETR pin<br />

ETR<br />

0<br />

1<br />

ETP<br />

TIMx_SMCR<br />

divider<br />

/1, /2, /4, /8<br />

ETPS[1:0]<br />

TIMx_SMCR<br />

ETRP<br />

CK_INT<br />

filter<br />

downcounter<br />

ETF[3:0]<br />

TIMx_SMCR<br />

TRGI<br />

ETRF<br />

CK_INT<br />

(internal clock)<br />

external clock<br />

mode 1<br />

external clock<br />

mode 2<br />

internal clock<br />

mode<br />

ECE SMS[2:0]<br />

TIMx_SMCR<br />

CK_PSC<br />

For example, to configure the upcounter to count each 2 rising edges on ETR, use the<br />

following procedure:<br />

1. As no filter is needed in this example, write ETF[3:0]=0000 in the TIMx_SMCR register.<br />

2. Set the prescaler by writing ETPS[1:0]=01 in the TIMx_SMCR register<br />

3. Select rising edge detection on the ETR pin by writing ETP=0 in the TIMx_SMCR<br />

register<br />

4. Enable external clock mode 2 by writing ECE=1 in the TIMx_SMCR register.<br />

5. Enable the counter by writing CEN=1 in the TIMx_CR1 register.<br />

The counter counts once each 2 ETR rising edges.<br />

The delay between the rising edge on ETR <strong>and</strong> the actual clock of the counter is due to the<br />

resynchronization circuit on the ETRP signal.<br />

Doc ID 13902 Rev 9 333/995

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!