NRF52840 Watchdog Reset code question

Hello,

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?

Thanks

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. :face_with_peeking_eye:
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 :slight_smile: PJ

look up, the 2.9.2 breaks interrupt ithink

I am having a hard time following…
I don’t know what a BSP 2.9.2 is.

The only hardware I have is NRF52840 and a board of my own design. I am not using any other modules.

I tried the soft reset command in the watchdog, it didn’t work.

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 :slight_smile: PJ
be sure to change the HIGH NRF_GPIO_PIN_SENSE_HIGH to LOW and remove the delays that are noted for good Sleep!