I have an issue with my code. I have both a soft reset and a hard reset (watchdog)
except watchdog.WatchDogTimeout as e:
microcontroller.reset()
except Exception as e:
supervisor.reload()
My supervisor works just as I want. The software restarts in the case of an exception. The watchdog, though, does not auto run the code after restarting the board. I believe this is by design. But is there a way to get the board to re-run the code, without having to hit the reset switch, if the watchdog fires?
Hi there, and Welcome
There is an exploit, Are if you are using the BSP 2.9.2
You can call the system sleep function and not use a delay and with the interrupt pin don’t use the gpio pin number.
The watchdog can call the MCU sleep and it will briefly (ms.) then reset.
or have the watchdog call the SoftDevice system reset maybe?
HTH
GL PJ
Hi there,
Are you using Arduino IDE?
either way if you call the Sleep function when the watchdog fires, the MCU will be reset.
Like this:
void goToPowerOff() {
//sleepFlash();
setLedRGB(false, false, false);
Serial.println("Going to SLEEP System OFF Tap to WAKE \n");
display.clearDisplay();
display.setCursor(10, 8);
display.setTextSize(3);
display.print("SLEEP");
display.display();
delay(500);
display.clearDisplay();
display.display();
setupDoubleTapInterrupt(); // not needed here, if already applied..
delay(2000); // delay seems important to apply settings, before going to System OFF
//Ensure interrupt pin from IMU is set to wake up device
// nrf_gpio_cfg_sense_input(digitalPinToInterrupt(int2Pin), NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
delay(2000); // delay seems important to apply settings, before going to System OFF
uint32_t pin = D2;
pin = g_ADigitalPinMap[pin];
nrf_gpio_cfg_sense_input(pin, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
delay(2000); //15 seconds before turns off (if USB is plugged in, that circuit will still draw 2mA)
Serial.println(" You're NOT doing anything, I'll Sleep.");
delay(2000);
sd_power_system_off();
NRF_POWER->SYSTEMOFF = 1;
}
HTH
GL PJ
be sure to change the HIGH NRF_GPIO_PIN_SENSE_HIGH to LOW and remove the delays that are noted for good Sleep!