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.

RM0008<br />

General-purpose timer (TIMx)<br />

Table 75.<br />

Counting direction versus encoder signals<br />

Active edge<br />

Level on opposite<br />

signal (TI1FP1 for<br />

TI2, TI2FP2 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 133 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, IC1FP1 mapped on TI1).<br />

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

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

● CC2P=’0’ (TIMx_CCER register, IC2FP2 non-inverted, IC2FP2=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 is enabled).<br />

Figure 133. Example of counter operation in encoder interface mode.<br />

forward<br />

jitter<br />

backward<br />

jitter<br />

forward<br />

TI1<br />

TI2<br />

Counter<br />

up down up<br />

Figure 134 gives an example of counter behavior when IC1FP1 polarity is inverted (same<br />

configuration as above except CC1P=’1’).<br />

Doc ID 13902 Rev 9 345/995

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

Saved successfully!

Ooh no, something went wrong!