AnsweredAssumed Answered

Encoder Read And Index Pulses

Question asked by pettersson.rober.001 on Feb 6, 2013
Latest reply on Feb 8, 2013 by malund.erik
Im using a quadrature encoder hooked up to TIM3-CH1/2 and it works fine, counting both edges, up and down.

 First question is how to read the TIM3-counter values from within a regular (50 us) ISR. Using TIM_GetCounter(TIM3) will cause a problem because the counter-value may be read at a time where it is being updated (written) and therefore generating a corrupt value. How to do this and make sure the value read is a correct (non corrupted) one ?

Second question is about using a index-pulse coming from my encoder. This index-pulse should be used for checking the encoder counter value to make sure it is not drifting over one revolution. I cannot use any interrupts to do this.

Is it possible to having the index-pulse generating a capture of the TIM3-counter and also transfer this (using double-buffered DMA) to a variable in memory ?

The index-pulse is coming into TIM3-CH3, but since TIM3 is already setup in encoder-count mode, would it even be possible to have the TIM3-CH3 to trigger a capture of the counter as well as initating a DMA-transfer ?

Thanks for any help with this!