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

configure TIMx_ARR before starting. in the same way, the capture, compare, prescaler,<br />

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

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

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

the incremental encoder and 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 and TI2 don’t switch at the<br />

same time.<br />

Table 69. Counting direction versus encoder signals<br />

Active edge<br />

Counting on<br />

TI1 only<br />

Counting on<br />

TI2 only<br />

Counting on<br />

TI1 and TI2<br />

Level on<br />

opposite<br />

signal (TI1FP1<br />

for TI2, TI2FP2<br />

for TI1)<br />

TI1FP1 signal TI2FP2 signal<br />

Rising Falling Rising Falling<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 and trigger a counter reset.<br />

Figure 112 gives an example of counter operation, showing count signal generation and<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’, CC1NP=’0’, and IC1F = ‘0000’ (TIMx_CCER register, TI1FP1 non-inverted,<br />

TI1FP1=TI1).<br />

● CC2P=’0’, CC2NP=’0’, and IC2F = ‘0000’ (TIMx_CCER register, TI1FP2 non-inverted,<br />

TI1FP2= TI2).<br />

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

edges).<br />

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

Doc ID 018909 Rev 3 382/1416

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

Saved successfully!

Ooh no, something went wrong!