You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may or may not work as hoped/expected depending on where and when the counter values change.
ie if a interrupt is generated while changing value.. in a different area of code
I have included a snippet of code. for esp32 external interrupt.
`const byte interruptPin = 25;
volatile int interruptCounter = 0;
int numberOfInterrupts = 0;
portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
void IRAM_ATTR handleInterrupt() {
portENTER_CRITICAL_ISR(&mux); // this prevent collisions during a write
interruptCounter++;
portEXIT_CRITICAL_ISR(&mux); // release the lock
}
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); //lock to prevent write collision while we change the value
interruptCounter--;
portEXIT_CRITICAL(&mux);// unlock
numberOfInterrupts++;
Serial.print("An interrupt has occurred. Total: ");
Serial.println(numberOfInterrupts);
}
}`
The text was updated successfully, but these errors were encountered:
SigkSens/SigkSens/src/sensors/digitalIn/digitalIn.cpp
Line 106 in 0e13d46
This may or may not work as hoped/expected depending on where and when the counter values change.
ie if a interrupt is generated while changing value.. in a different area of code
I have included a snippet of code. for esp32 external interrupt.
The text was updated successfully, but these errors were encountered: