can you look at the A B signals of encoder on the oscilloscope ? ( becouse I have the same code like you and I can read encoder with this code ) second ) is the compiler giving any warnings during compilation ?
I copyed your code into my project and it works.Please check if your encoder working properly.By the way,there seems a strange problem with this code,though TIM2 is configed into COUNTUP mode,the TIM2->CNT value keeps decreasing instead of increasing.
From: Thiago Navarro
Posted: Thursday, December 02, 2010 11:47 AMSubject: Encoder Problem
Hey, I am trying to work this encoder interface, but I haven´t had good results. When I debug my code , roll the encoder and watch the TIM2->CNT, its value is always (0 or 65535) or (0 or 1). Here is my code.