2017-11-08 12:15 AM
On STM32F777 I have configured TIM2 as encoder counter with a period of 8192 (i.e. the CNT will wrap at 8192, see ARR register).
Everything works as expected until I reset the CNT by setting TIM2->CNT=0. In this case the first time CNT doesn't wrap to the expected period value of 8192, it will wrap at (8192 - CNTvalueAtReset): if CNT is 1192 and I reset it, the first time CNT will wrap at 7000 instead than 8192.
After this first time everything works as expected.
Is there some register I can set when resetting the counter to avoid this behaviour?
#stm32-encoderSolved! Go to Solution.
2017-11-08 01:09 AM
I observe it through a tcp connection.
I just discovered it was my fault: I was resetting CNT in two different places in my code and I completely forgot about one of them!
When resetting it only in one place everything works as expected.
Sorry and thank you for your interest.
2017-11-08 12:31 AM
How do you observe CNT and the wraparound?
JW
2017-11-08 01:09 AM
I observe it through a tcp connection.
I just discovered it was my fault: I was resetting CNT in two different places in my code and I completely forgot about one of them!
When resetting it only in one place everything works as expected.
Sorry and thank you for your interest.