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 />

Advanced-control timers (TIM1&TIM8)<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 />

Figure 76. Control circuit in external clock mode 2<br />

f CK_INT<br />

CNT_EN<br />

ETR<br />

ETRP<br />

ETRF<br />

Counter clock = CK_CNT = CK_PSC<br />

Counter register 34<br />

35 36<br />

13.3.5 Capture/compare channels<br />

Each Capture/Compare channel is built around a capture/compare register (including a<br />

shadow register), a input stage for capture (with digital filter, multiplexing <strong>and</strong> prescaler) <strong>and</strong><br />

an output stage (with comparator <strong>and</strong> output control).<br />

Figure 77 to Figure 80 give an overview of one Capture/Compare channel.<br />

The input stage samples the corresponding TIx input to generate a filtered signal TIxF.<br />

Then, an edge detector with polarity selection generates a signal (TIxFPx) which can be<br />

used as trigger input by the slave mode controller or as the capture comm<strong>and</strong>. It is<br />

prescaled before the capture register (ICxPS).<br />

Doc ID 13902 Rev 9 269/995

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

Saved successfully!

Ooh no, something went wrong!