09.12.2012 Views

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>RM0090</strong> General-purpose timers (TIM9 to TIM14)<br />

Figure 186. Control circuit in gated mode<br />

Slave mode: Trigger mode<br />

TI1<br />

cnt_en<br />

Counter clock = ck_cnt = ck_psc<br />

The counter can start in response to an event on a selected input.<br />

In the following example, the upcounter starts in response to a rising edge on TI2 input:<br />

1. Configure the channel 2 to detect rising edges on TI2. Configure the input filter duration<br />

(in this example, we don’t need any filter, so we keep IC2F=’0000’). The capture<br />

prescaler is not used for triggering, so you don’t need to configure it. The CC2S bits are<br />

configured to select the input capture source only, CC2S=’01’ in TIMx_CCMR1 register.<br />

Program CC2P=’1’ and CC2NP=’0’ in TIMx_CCER register to validate the polarity (and<br />

detect low level only).<br />

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

Select TI2 as the input source by writing TS=’110’ in TIMx_SMCR register.<br />

When a rising edge occurs on TI2, the counter starts counting on the internal clock and the<br />

TIF flag is set.<br />

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

resynchronization circuit on TI2 input.<br />

Figure 187. Control circuit in trigger mode<br />

Counter register 30 31 32 33 34<br />

35 36 37 38<br />

TIF<br />

TI2<br />

cnt_en<br />

Counter clock = ck_cnt = ck_psc<br />

Write TIF=0<br />

Counter register 34<br />

35 36 37 38<br />

TIF<br />

Doc ID 018909 Rev 3 496/1416

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

Saved successfully!

Ooh no, something went wrong!