2008-10-29 08:34 PM
Encoder interface
2011-05-17 03:48 AM
I have an encoder interface setup, using the auto-reload to loop around for the CPR of the encoder (i.e. 0-799).
Can the timer(s) be setup to give an underflow/overflow to chain to a longer (32 bit) reading. Or can the timers be chained to give this behaviour. Thanks for any help.2011-05-17 03:48 AM
I'd like to know how you set up your encoder interface. I haven't found any good examples anywhere.
As for chaining timers in encoder mode to get 32 bits, that would be a nice feature, wouldn't it? I have done it for two timers, but not in encoder mode. It should be pretty much the same as long as you are only going in one direction. The additional complication is that you could be overflowing or underflowing, but the update trigger doesn't tell the slave timer which one it was. Your only option might be to increment/decrement the upper word in an ISR.2011-05-17 03:48 AM
Hi,
I couldn't find any example as well. I have done it like that.Code:
<BR> <BR> TIM2->CCMR1=(u16)0xF1F1; <BR> TIM2->CCMR2=(u16)0x0000; <BR> TIM2->SMCR=(u16)0x0003; <BR> TIM2->CR1=(u16)0x0001; <BR> TIM2->CR2=(u16)0x0000; <BR> TIM2->CCER=(u16)0x0011; <BR> TIM2->PSC=(u16)0x0000; <BR>
Then to read value:Code:
<BR> TempEnkoder=(short)TIM2->CNT; <BR>
[ This message was edited by: jaroslaw.oska on 30-10-2008 09:05 ]