29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

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.

Advanced-control timers (TIM1&TIM8)<br />

RM0008<br />

repetition counter, trigger output features continue to work as normal. Encoder mode <strong>and</strong><br />

External clock mode 2 are not compatible <strong>and</strong> must not be selected together.<br />

In this mode, the counter is modified automatically following the speed <strong>and</strong> the direction of<br />

the incremental encoder <strong>and</strong> its content, therefore, always represents the encoder’s<br />

position. The count direction correspond to the rotation direction of the connected sensor.<br />

The table summarizes the possible combinations, assuming TI1 <strong>and</strong> TI2 don’t switch at the<br />

same time.<br />

Table 71.<br />

Counting direction versus encoder signals<br />

Active edge<br />

Level on<br />

opposite<br />

signal (TI1FP1<br />

for TI2, TI2FP2<br />

for TI1)<br />

TI1FP1 signal<br />

TI2FP2 signal<br />

Rising Falling Rising Falling<br />

Counting on<br />

TI1 only<br />

Counting on<br />

TI2 only<br />

Counting on<br />

TI1 <strong>and</strong> TI2<br />

High Down Up No Count No Count<br />

Low Up Down No Count No Count<br />

High No Count No Count Up Down<br />

Low No Count No Count Down Up<br />

High Down Up Up Down<br />

Low Up Down Down Up<br />

An external incremental encoder can be connected directly to the MCU without external<br />

interface logic. However, comparators are normally be used to convert the encoder’s<br />

differential outputs to digital signals. This greatly increases noise immunity. The third<br />

encoder output which indicate the mechanical zero position, may be connected to an<br />

external interrupt input <strong>and</strong> trigger a counter reset.<br />

The Figure 92 gives an example of counter operation, showing count signal generation <strong>and</strong><br />

direction control. It also shows how input jitter is compensated where both edges are<br />

selected. This might occur if the sensor is positioned near to one of the switching points. For<br />

this example we assume that the configuration is the following:<br />

● CC1S=’01’ (TIMx_CCMR1 register, TI1FP1 mapped on TI1).<br />

● CC2S=’01’ (TIMx_CCMR2 register, TI1FP2 mapped on TI2).<br />

● CC1P=’0’ (TIMx_CCER register, TI1FP1 non-inverted, TI1FP1=TI1).<br />

● CC2P=’0’ (TIMx_CCER register, TI1FP2 non-inverted, TI1FP2= TI2).<br />

● SMS=’011’ (TIMx_SMCR register, both inputs are active on both rising <strong>and</strong> falling<br />

edges).<br />

● CEN=’1’ (TIMx_CR1 register, Counter enabled).<br />

286/995 Doc ID 13902 Rev 9

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

Saved successfully!

Ooh no, something went wrong!