cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect encoder overflow (on STM32F767)?

Vaclav Zajic
Associate II

Hello, how can I detect encoder overflow on STM32F767? I want to increment a variable every time the encoder overflows. Thank you, Vaclav

2 REPLIES 2

You'd likely need to interrupt on the Update condition (ie CNT==0) or use the other CCRx to flag as it approaches limits. (ie CNT==CCR2, CC2 signals)

TIM2 and TIM5 should be 32-bit

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

There is no simplistic solution of this problem. Don't get caught by the trap of trying to rely solely on Update interrupt, you'll miss reversals. Instead, make sure that you'll read out the counter at least twice per revolution (for example using the update and two compare interrupts set at 1/3 and 2/3 of the full revolution, disabling themselves upon firing to avoid interrupt storm upon reversals, while re-enabling the other two) and write the logic needed to decode overflows from that. User reads should go through the same logic, paying meticulous attention to atomicity.

JW