Interrupt capabilities on certain pins


For hours I'm looking now for a solution :confused:
I'm using the ATSAMD21G18A and need wake up interrupts on inputs:
25 (PB8, physical pin 7)
26 (PB9, physical pin 8)
43 (PA13, physical pin 22)

For sleep I'm using this lib-> #include "ArduinoLowPower.h"

How can I activate those inputs for interrupt capability? Seems that in the standard definition file in the Arduino IDE "Arduino M0 Pro" those are not activated?

Hi timtailors,

The attachInterrupt() function enables the wake-up functionality by default.

The following code wakes up the SAMD21 from deep sleep from a logic high interrupt on pin A1 (PB08), turns on the LED on D13, then after 1 second swiches it off and goes back to sleep again:

// Put the CPU core into deep sleep and awake with a logic HIGH interrupt on analog pin A1
void setup() { 
  pinMode(13, OUTPUT);                          // Set digital pin 13 to an output
  pinMode(A1, INPUT_PULLDOWN);                  // Set analog pin A1 to an input with an internal pull-down resistor
  attachInterrupt(A1, interrupt, HIGH);         // Set up an interrupt on analog pin A1 on a logic HIGH level
  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;            // Set up the CPU to enter low power STANDBY mode (rather than IDLE mode)

void loop() 
  delay(1000);                                  // Wait for 1 second
  digitalWrite(13, LOW);                        // Set D13 output to logic LOW
  __WFI();                                      // Put the SAMD21 into deep sleep Zzzzzzz....

void interrupt()                                // Interrupt Service Routine (ISR)
  digitalWrite(13, HIGH);                       // Set D13 output to logic HIGH

Hi Martin,

took me a while now to test it again and it's working like you suggested. Great! Thanks!
I'm wondering what's the benefit then with an additional library if it works without as easy and even better?

I need 5 different pins which are capable waking up the chip from sleep but I assume that's just another "attachInterrupt".. will try it tomorrow.

This chapter from Joseph Yiu's book "A defintive guide to the ARM Cortex M0/M0+" provides an excellent summary of the M0+'s ultra low power features:

Thanks! Indeed even if I have to admit that I still didnt understand everything.
I need interrupt which wakes up the M0 on rising and on Low/or falling.

I also tried the rocket low-power lib but there's no rising/falling feature. However with that library PA13 is working as an interrupt from sleep when changing the lib to LOW. Hower for other pins I need the rising/falling option :confused: