For the arduino Nano 33 BLE Sense board, the standard avr/wdt.h
is not available. And it seems that no standard library provides it. How to use the watchdog system for this board ? I found no full information about it.
I've found the page https://www.mysensors.org/apidocs/group__avr__watchdog.html which allow to configure the reboot mode. And it works. But no way to configure the interruption mode with ISR()
function. Moreover, there's no explanation about the manipulation of used register/variables for any fine configuration.
Simple code example with regular asynchronous stuff using the watchdog ISR() mechanism. It which works well with ATmega328 (e.g.UNO). But I do not find equivalent configuration for the Nano 33 BLE using the nRF52840.
# include <avr/wdt.h>
volatile byte led;
int k;
ISR(WDT_vect) {
Serial.println("Asynchronous stuff in ISR() function");
digitalWrite(LED_BUILTIN,led);
led=!led;
}
void setup() {
pinMode(LED_BUILTIN,OUTPUT);
led=0;
Serial.begin(9600);
while(!Serial) {}
Serial.println("== R E B O O T ==");
WDTCSR = ( 1 << WDE ) | ( 1 << WDCE );
WDTCSR = ( 1 << WDP2 ) | ( 1 << WDP0 ) | ( 1 << WDIE ) ; // Interruption and timeout 1/2 s
}
void loop() {
Serial.print("Loop #");
Serial.println(k);
if (k++%2) {
Serial.println("Some stuff (even branch)");
delay(1200);
}
else {
Serial.println("Some stuff (odd branch)");
delay(4800);
}
}
Thks.