2023-01-24 12:29 PM
Hi there!
i start to work with a rotary encoder, i configurate a timer 3:in this way and i enable the interrupt .
for read the encoder inside the timer interrupt i write nuber= (TIM3->CNT)>>2;
so when i read the varible the first time i see 0 - 1- 2- 3 afther for three
time show 0 - 1 - 2 and the fourth time 0 - 1- 2- 3 and again 0-1-2 for three time and the fourth time the 0-1-2-3 . I don't understand why please someone can help me ? and someone try to read encoder with DMA ,and in which because i diden't find any tutorial in internet
Thank you soo much
Sergio
2023-01-24 01:05 PM
Which STM32?
Set ARR (Period) to 15.
Although I would leave it at its maximum (0xFFFF).
> try to read encoder with DMA
Why? I don't think you need that.
JW
2023-01-24 01:40 PM
thanks for the fast replace, please can you tell me why with 15 it works ?
2023-02-01 08:27 AM
With ARR=12 CNT can count from 0 to 12 and then wraps around to 0. If you observe nuber= (TIM3->CNT)>>2, then when CNT=0..3 --> number=0; CNT=4..7 --> number=1, CNT=8..11 --> number=2,. but number = 3 only when CNT=12, so the "slot" from which number = 3 results is 4x smaller than the other "slots".
JW