Interrupt is not being detected by the rp2040

So I am attempting to listen to an interrupt from a specific pin, but the function attached to the interrupt is not executing.

Could someone point out what im doing wrong? Im using a rp2040 raspberry pi pico board using the latest core by Earle E Philhower V2.2.0

bool pressEvent = false;
const int interruptPin = 9;

void switchPressed() {
  pressEvent = true;
}

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Starting");

  pinMode(interruptPin, INPUT);

  Serial.println("Listening to touchpad");
  attachInterrupt(digitalPinToInterrupt(interruptPin), switchPressed, RISING);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print(digitalRead(interruptPin));
  Serial.print("\t");
  Serial.println(pressEvent);

}

As you can see in the serial monitor the print for pressEvent remains 0 even though digitalRead sees a logic high. The signal is there, so it would seem to point that im doing something wrong with my code?

Try declaring pressEvent as volatile.
BTW, you never set it false again.

declaring it volatile sadly did not solve it :frowning:

volatile bool pressEvent = false;

I intentionally did not set it to false so that i can clearly see if the ISR was executed. This is only a simplified code anyway to demonstrate my problem

HackadayU course #2 is on interrupts: you may find some jewels.

Something is wrong with the core, rolled back to v1.13.0 it works... will be posting on earl's github

1 Like

Thanks for posting the update

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.