ESP32 interrupt issue in Rotary Encoder usage using pcnt unit

vishnuwar
Posts: 1
Joined: Sun Feb 09, 2025 6:04 pm

ESP32 interrupt issue in Rotary Encoder usage using pcnt unit

Postby vishnuwar » Sun Feb 09, 2025 6:11 pm

  1. ###############################################
  2.  
  3. Facing Issue with the interrupt generation on the pcnt threshold watchpoint.
  4.  
  5. When watchpoint is added as threshold, apart from the high limit and low limit, we are facing issue such that, the interrupt is first generated at the threshold value, after crossing zero, but lets say, in between if I change the pcnt threshold, by deleting the current watchpoint and add another watchpoint which should get triggered in a further count, the interrupt does not get generated, or reaching till pcnt_default_isr, and it will be triggered only after the limit is touched and the counter value gets zeroed, and again reaches the same value.
  6.  
  7. using version ESP IDF 5.1
  8.  
  9. Here below is a flow prints which was added in the rotary encoder flow.
  10.  
  11. New configuration : CurrPos : 29 || New Target : 327
  12.     pcnt: watchers[0] = [0, 327]                    // Target set for 327
  13.     pcnt: watchers[1] = [-1, 0]                     // Invalid
  14.     pcnt: watchers[2] = [2, -3576]                  // Lower threshold
  15.     pcnt: watchers[3] = [3, 3576]                   // Upper threshold
  16.     pcnt: watchers[4] = [-1, 0]                     // Invalid
  17. ###############################################
  18.  
  19. Curr Cycle : 29     int_count : 1
  20. Curr Cycle : 62     int_count : 1
  21. Curr Cycle : 207    int_count : 1
  22. Curr Cycle : 308    int_count : 2                   // Interrupt recieved for watchpoint, int count incremented
  23. Motor position reached at 327, stopping motor       // Recieved interrupt, and motor stopped
  24.  
  25. ###############################################
  26. New configuration : CurrPos : 331 || New Target : 629
  27.     pcnt: watchers[0] = [0, 629]
  28.     pcnt: watchers[1] = [-1, 0]
  29.     pcnt: watchers[2] = [2, -3576]
  30.     pcnt: watchers[3] = [3, 3576]
  31.     pcnt: watchers[4] = [-1, 0]
  32. ###############################################
  33.  
  34. Curr Cycle : 331    int_count : 2
  35. Curr Cycle : 365    int_count : 2
  36. Curr Cycle : 410    int_count : 2
  37. .
  38. Curr Cycle : 611    int_count : 2
  39. [color=#FF0000]Curr Cycle : 661    int_count : 2                   // Crossed new target which was 629, but interrupt count not incremented[/color]
  40. Curr Cycle : 711    int_count : 2
  41. .
  42. Curr Cycle : 2634   int_count : 2
  43. Curr Cycle : 3543   int_count : 2
  44. Curr Cycle : 18     int_count : 3                   // High limit interrupt:  added interrupt count from 2 to 3, but ignored as its not the one which we are looking for
  45. Curr Cycle : 68     int_count : 3
  46. Curr Cycle : 573    int_count : 3
  47. Curr Cycle : 623    int_count : 3
  48. Curr Cycle : 674    int_count : 4
  49. Motor position reached at 629, stopping motor

Who is online

Users browsing this forum: No registered users and 141 guests