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.
ISR()
mechanism at the end of the counting of the watchdog timer.NRF_WDT->CONFIG = 0x01;
and so on. I don't see that in your code. Your code in setup directly writes to MCU registers that do not exist on the nano 33 BLE. To configure it, you must take over those parts. If and how the watchdog interrupt can be intercepted on the nRF processor is another question. Typically the watchdog interrupt just does reset - normally it is intended not to happen within your firmware. If your idea is to time the execution of some code you might use a timer interrupt for this - not the watchdog.