cancel
Showing results for 
Search instead for 
Did you mean: 

why isnt my encoder counter going down wen i turn the encoder the opposite way im new to programming and cant figure this out im using the stm32f407 btw im using cmsis not hal

Franksterb92
Associate III
 
4 REPLIES 4

Code looks good, maybe your signals (hardware) aren't working as you expect. Observe GPIOA_IDR register in debugger, while toggling the pins (slowly turning encoder). Or, observe signals using oscilloscope directly on the mcu pin.

What hardware is this? Isn't it a Disco or EVAL board, where PA9 is loaded by the USB-VBUS capacitor?

JW

the board is a disco and I thought about that led cause the led does light up every time I turn the rotary encoder but I don't have an oscilloscope yet anyway. ill change to a different timer and see if that works. what's weird is there is a bit in TIMx->CR its a direction bit and last night I was playing with it and intermittently the bit would go to 1 indicating that the counter is down counting thanks for the advice tho im new to stm32 and programming for that matter

I changed to TIM5 and now its working nice now I just have to figure out how to tune the counter to my encoder so that one click adds 1 to the counter instead of like 4 or 5 at a time thanks for the response

Postprocess it in software (divide by 4 the value you read out)​.

JW​