cancel
Showing results for 
Search instead for 
Did you mean: 

Can you read and reset Counter in Quadrature Encoder Mode via ISR?

MLowe.3
Associate II

I'm interested in motor speed control. When reading the documentation on the timer modules, it talked about having the counter value saved using a different timer or DMA. What I am wondering is can I read the value manually via an ISR and reset it to 0? Also if you start at 0 and count down I assume it does does twos complement and thus represents -1 by a counter value with full bits?

Thanks

1 REPLY 1
Piranha
Chief II

> What I am wondering is can I read the value manually via an ISR and reset it to 0?

Yes.

> Also if you start at 0 and count down I assume it does does twos complement and thus represents -1 by a counter value with full bits?

No, it will load the CNT with the value of ARR and generate an update event. Of course, if you set ARR to a value corresponding to -1, which is also the reset value for ARR, then it will load that. Read the section "Downcounting mode" in reference manual. Also AN4776 is recommended.