XIAO BLE Sense in deep sleep mode

Still not have been able to make the lowpower mode to work properly after reading all this thread… I can make the deepsleep work. I can assign a pin to wake from deepsleep, but it do a full system reset…

But I need the system to wakeup automatically at interval ( like every minutes to report then go back to sleep). So I need not a total sleep, but just lowering the power at max.

I can have a timer generate periodic interrupt. But if I use sd_app_evt_wait, the system don’t stop, it just keep like there was no instruction.


#include <Arduino.h>
#include <Adafruit_TinyUSB.h> // for Serial
#include <bluefruit.h>
#include "Arduino_nRF5x_lowPower.h"
// These define's must be placed at the beginning before #include "NRF52TimerInterrupt.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
// Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
#define TIMER_INTERRUPT_DEBUG         0
#define _TIMERINTERRUPT_LOGLEVEL_     3
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "NRF52TimerInterrupt.h"

#define WAKE_LOW_PIN  D0
// here I have handler for interrpupt... not present because it work fine....


void loop() {

    // setup your wake-up pins.
    pinMode(WAKE_LOW_PIN,  INPUT_PULLUP_SENSE);    // this pin (WAKE_LOW_PIN) is pulled up and wakes up the feather when externally connected to ground.
            
    digitalWrite(LED_BLUE, HIGH);          // just turn the blue led to show that i'M sleep mode

    sd_power_mode_set(POWER_MODE_LOW_POWER);
    Serial.print(millis());   // print the time to see if when I get bac
    __WFE();   // I suppose this is to enable event  for wake up
    __WFI();    // I suppose this is to enable interruption for wake up
    delay(2000);    // from comment I have seen on that thread, need to put a delay here
   
    sd_app_evt_wait();            // Here the system should go in standby , but does'nt
    //NRF_POWER->SYSTEMOFF = 1;   // If a put this active, the process stop, and will restart on pin activation, but the timer seem to freeze, When it restart, jump to reset
    digitalWrite(LED_BLUE, LOW);    // this should turn off the blue led telling me the programm has reach this point, but the led never go off immediately with sd_app_evt_wait, and never with SYSTEM OFF

`Texte préformaté`