Wake up SAMD21 from external interrupt doesn't work

Hi all,

I'am working on a personnal board build with an atsamd21e18a. I'am actually working on sleep mode. I make a function to put samd21 in sleep mode like that. I use RTCZero library.

So in my setup function I've something like this

RTCZero rtc;

void setup(){
    // Set the XOSC32K to run in standby
    .... other line code ....
    attachInterrupt(digitalPinToInterrupt(PIN_USER_BUTTON), wakeUpButtonUser, CHANGE);
    ...other line....

So in my setup I intialise rtc and I attach an interrupt in my user button. This button is used to power on or power off my board.

My function goTosleep() :


In my function wakeUpButtonUser I have a simple if/else statement. If the user pressed the button more than 3 seconds samd21 go to sleep with goToSleep() function, else if it's less than 3 seconds I want wake up the board and light up my led but it's doesn't work.

Here my wakeUpButtonUser function, user_button is object create from C++ for my button.

void wakeUpButtonUser(){
    if (userButton.isPressed())
        uint32_t time_pressed = userButton.getTimePressed();
        if (time_pressed >= temps_on && time_pressed < temps_off)
             //here I have code to light up a led

This fuction works because if I comment the line `goToSleep(), I can read on my serial ON or OFF depending the time I pressed my button and the led works also because I can light up led before going to sleep. But when my board go to sleep, she's never wake up I don't understand why, I missed something?

attachinterrupt() will not work with sleep mode, There will be cases where other wake up resources is required on top of the RTC. For example, Dollar General Survey RTC wake up is used to perform a periodic tasks while an external When I push it again it doesn't seem to trigger the interrupt.

Ok so maybe I need to use Arduino LowPower here in this example external interrupt is used to wake up samd21 like thaht LowPower.attachInterruptWakeup(pin, repetitionsIncrease, CHANGE);

I've tried to use ArduinoLowPower library I have the same issue, I can't wake up my board after calling LowPower.sleep(), I really don't understand any help?

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