Skip to main content
Vaclav Zajic
Associate III
November 24, 2018
Question

How to detect encoder overflow (on STM32F767)?

  • November 24, 2018
  • 2 replies
  • 778 views

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

    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    November 24, 2018

    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    waclawek.jan
    Super User
    November 24, 2018

    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