09.12.2012 Views

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>RM0090</strong> General-purpose timers (TIM2 to TIM5)<br />

1. Configure the external trigger input circuit by programming the TIMx_SMCR register as<br />

follows:<br />

– ETF = 0000: no filter<br />

– ETPS = 00: prescaler disabled<br />

– ETP = 0: detection of rising edges on ETR and ECE=1 to enable the external clock<br />

mode 2.<br />

2. Configure the channel 1 as follows, to detect rising edges on TI:<br />

– IC1F = 0000: no filter.<br />

– The capture prescaler is not used for triggering and does not need to be<br />

configured.<br />

– CC1S = 01 in TIMx_CCMR1 register to select only the input capture source<br />

– CC1P = 0 in TIMx_CCER register to validate the polarity (and detect rising edge<br />

only).<br />

3. Configure the timer in trigger mode by writing SMS=110 in TIMx_SMCR register. Select<br />

TI1 as the input source by writing TS=101 in TIMx_SMCR register.<br />

A rising edge on TI1 enables the counter and sets the TIF flag. The counter then counts on<br />

ETR rising edges.<br />

The delay between the rising edge of the ETR signal and the actual reset of the counter is<br />

due to the resynchronization circuit on ETRP input.<br />

Figure 158. Control circuit in external clock mode 2 + trigger mode<br />

TI1<br />

CEN/CNT_EN<br />

ETR<br />

Counter clock = CK_CNT = CK_PSC<br />

Counter register 34<br />

35 36<br />

TIF<br />

Doc ID 018909 Rev 3 448/1416

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

Saved successfully!

Ooh no, something went wrong!