8000 interrupts on slow edges · Issue #1229 · espressif/arduino-esp32 · GitHub
[go: up one dir, main page]

Skip to content
interrupts on slow edges #1229
Closed
Closed
@404-baitnotfound

Description

@404-baitnotfound

Description:

Hey I would like to use interrupts on buttons. However if I put a cap for debouncing the slow rising/falling edge triggers between 15/25 events with 100nF / 10K. Bigger Caps only increase the number of events. No cap results in a bouncy signal.
Also it seems that Falling/Rising edge does not work on slow edges.

If the dectection is depending on the rise/fall time than I don't see a reliable way of implementing anything with interrupts.

Sketch:

#include <Arduino.h>

const byte interruptPin = 27;
volatile int interruptCounter = 0;
int numberOfInterrupts = 0;
 
portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
 
void IRAM_ATTR handleInterrupt() {
  
    portENTER_CRITICAL_ISR(&mux);
      interruptCounter++;
    portEXIT_CRITICAL_ISR(&mux);

  
}
 
void setup() {
 
  Serial.begin(115200);
  Serial.println("Monitoring interrupts: ");
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, FALLING);
}
 
void loop() {
 
  if(interruptCounter>0){
 
      portENTER_CRITICAL(&mux);
      interruptCounter--;
      portEXIT_CRITICAL(&mux);
 
      numberOfInterrupts++;
      Serial.print("An interrupt has occurred. Total: ");
      Serial.println(numberOfInterrupts);
  }
  delay(50);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0