Feather M0/ Ardunio Zero - SAMD21 does not wake up from deepSleep

Hello guys! I need your help!

I try to brint my device back from sleep while pushing a button, but it never wake up. What did i missing? The button works, because i use the button several times in the code...

// DeepSleep test
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
void isr() { } // Interrupt Service Routine

void sleep(){

//setAnnouncement( "Good Night!", "ZZZzzzZZZzzz", 2000, true);

 u8g2.setPowerSave(1);  

 attachInterrupt (digitalPinToInterrupt(5), isr, CHANGE);  // attach interrupt handler
 
 rf69.sleep();

 digitalWrite(DIAGLED, LOW);

 USBDevice.standby();
 
 delay(500);

 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
 
 __DSB();
 __WFI();
 
 detachInterrupt(digitalPinToInterrupt(5));
 digitalWrite(DIAGLED, HIGH);

 SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;

}

What did i missing?

Posting code that actually compiles.

Sorry, was just a code part of my whole program. I extracted it now properly for testing.

The LED is my indicator for sleep and wake up.

#define DIAGLED     13
const uint8_t triggerPin = 5;
const uint8_t extraButtonPin = 6;

void setup() {
  
  pinMode(triggerPin, INPUT_PULLUP);
  pinMode(extraButtonPin, INPUT_PULLUP);
  pinMode(DIAGLED, OUTPUT);
}


void loop() {
  
  if (digitalRead(triggerPin) == LOW) {
    sleep();
  }
  
}

// DeepSleep test
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
void isr() { } // Interrupt Service Routine

void sleep(){

//setAnnouncement( "Good Night!", "ZZZzzzZZZzzz", 2000, true);

 //u8g2.setPowerSave(1);  set display to sleep

 attachInterrupt (digitalPinToInterrupt(extraButtonPin), isr, CHANGE);  // attach interrupt handler
 
 //rf69.sleep(); set RFM69 to sleep

 digitalWrite(DIAGLED, LOW);

 USBDevice.standby();
 
 delay(500);

 SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
 
 __DSB();
 __WFI();
 
 detachInterrupt(digitalPinToInterrupt(extraButtonPin));
 //u8g2.setPowerSave(1);  set display to sleep
 digitalWrite(DIAGLED, HIGH);

 SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;

}

And, with that code, you know it doesn't wake up because?

shouldn't it wake up on this part here... the LED is my indicator. Or did I misunderstand there somthing? The __WFI() is where the codes run again after I wake up with the interrupt pin.

...
__WFI();
 
 detachInterrupt(digitalPinToInterrupt(extraButtonPin));
 //u8g2.setPowerSave(1);  set display to sleep
 digitalWrite(DIAGLED, HIGH);
...

The __WFI() is where the codes run again after I wake up with the interrupt pin.

So, now you want us to guess where __WFI() is defined, and what it does. Is the POST ALL OF YOUR CODE concept too difficult for you?

The is a function from the library WAIT FOR INTERRUPTION... there is not more to show. I thought it is a common feature for watch to an interrupt while sleeping. For now this should be the complete code.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/BABFEFIG.html

All the other things in the code is just handling other stuff.

That link is to documentation for some stuff that you have not proven you are using. If you can't post all of your code, or a minimal example that illustrates the problem, with all include files shown, and links to all non-standard libraries, you can't realistically expect help.

I just took some code snippets from github, but that's maybe the total wrong way. I wanna start from beginning.

Its not easy for me, because its the first time I look that much deep into such rare functions. Sorry for that!

I use an Adafruit Feather M0 with RFM69 module and SSD1306 OLED.

I found some documentation about how bring the RFM modul into sleep.

here I found the documentation about how to bring the OLED into sleep mode.

Everything easy...

Now I have to take care of the main part, the SAMD21 on my Feather. Here I stuck. So before I code I should understand how this works. If someone has a hint or a good link, please share it with me. I try my best to find something by my own.

Hi Folks,

i have a problem with the adafruit m0 rfm69 dev board, im using the standard RTCZERO library.

its seems to go into "standby mode" grand drawing approx 1mA would prefer this to be lower 2/300uA.

its when the device wakes up it seems to crash/lock up and i have to reset the board.

I am trying to get the device to wake up once and hour measure a sensor and go back to sleep. but for the purposes of testing i have set the firmware to flash an Led a few times on wake up.

any help much appreciated

#include <RTCZero.h>

/* Create an rtc object */
RTCZero rtc;

/* Change these values to set the current initial time */
const byte seconds = 00;
const byte minutes = 00;
const byte hours = 00;

/* Change these values to set the current initial date */
const byte day = 17;
const byte month = 11;
const byte year = 15;

void setup()
{
delay(20000);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);

rtc.begin();

rtc.setTime(hours, minutes, seconds);
rtc.setDate(day, month, year);

rtc.setAlarmSeconds(10);
rtc.enableAlarm(rtc.MATCH_SS);

rtc.attachInterrupt(alarmMatch);

rtc.standbyMode();
}

void loop()
{
delay(1000);
digitalWrite(LED_BUILTIN, LOW);

rtc.setAlarmSeconds(10);
rtc.enableAlarm(rtc.MATCH_SS);
rtc.attachInterrupt(alarmMatch);

rtc.standbyMode(); // Sleep until next alarm match
}

void alarmMatch()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}