When I use Arduino nano 33 ble for projects, I want to use the watchdog (WDT) and find that #include < AVR / WDT. H > cannot be used. I checked the board chip information, which contains a watchdog timer, but I can't find the corresponding interface to use it. I'd like to ask you to help me refer to what you should do.
Since the "Arduino Mbed OS Nano Boards" platform of the Nano 33 BLE is based on the Mbed OS framework, you can try using Mbed OS's watchdog API: https://os.mbed.com/docs/mbed-os/v6.12/apis/watchdog.html
Just use the mbed namespace by prefixing the Mbed API references with mbed::
Hi @pengdaliu. I did some investigation and it seems that the watchdog has not been implemented for the Nano 33 BLE. I apologize for having gotten your hopes up for a solution from Mbed OS.
Even though the Mbed OS API turned out to not be useful in this particular case, there are many parts of the API which are implemented for the Nano 33 BLE, so I'll go ahead and share a minimal demo of the Watchdog API as it could be used in an Arduino sketch for one of the boards that it does support:
When uploaded to one of the boards with Watchdog API implementation, such as the Nano RP2040 Connect, this will blink the onboard LED at 0.5 Hz. In this contrived example, the watchdog timer is simply being used as a 1000 ms delay . Since watchdog.kick() is never called, the timer times out after 1000 ms and the processor resets, which starts the next iteration of the blink.
There are two essential things you were missing from your sketch:
The #include directive for mbed.h
The mbed:: namespace scope on all references to Mbed OS API elements
Hello, I missed #include... in my screenshots, I actually do. The following is the result of compiling with your code, and there will still be errors. Is it because I am missing any library? I can't seem to find the mbed.h file or Watchdog.h file on the computer. I don't know if this is causing the problem.
Hi @pengdaliu. As I said above, you can't use the code I shared with the Nano 33 BLE. This error is normal and expected. So please forget all about Mbed OS. I'm sorry to have caused this confusion.
Thank you very much for your help. I have a question. Since I cannot use it, why include <mbed.h>or include<Watchdog.h>, this will not cause an error. Is my board not supported because this part of the function has not been developed yet?
No. The watchdog timer can be implemented, its just not using the commands of the arduino core. You need to use the underlying mbed and nrf52840 syntax.