![]() Note that we will do an infinite loop with a while loop.Īfter uploading the code, open the serial port to check the output. We can do all of these actions in the setup function, as indicated bellow. To trigger the hardware watchdog, we just need to disable the software watchdog timer and do an infinite loop. Nevertheless, it’s important to know that it exists, in order to troubleshoot spontaneous reboots of our programs. Fortunately, the ESP libraries implicitly reset the watchdog in many of the functions, so most of the time we don’t need to worry about feeding the watchdog. In order to explicitly restart the watchdog, we can call the wdtFeed method, specified here. Unfortunately, it’s not clear what is the default value of the watchdog timer when we call this function, and neither it is documented in the SDK of the ESP8266. Nevertheless, this value makes no effect and it is not used in the internal call of the SDK ESP8266 functions, as can be seen by the source code here.Īdditionally, in the header file, it’s clearly stated that, at the time, setting the timeout is not implemented. It’s important to note that an integer value needs to be passed as input argument of this method, which would correspond to the number of milliseconds for the watchdog to trigger. We can re-enable the software watchdog by calling the wdtEnable method, as indicated bellow. This is approximately what I got when testing it. As indicated in the comments of the wdtDisable method, if we stop the software watchdog by more that 6 seconds, the hardware watchdog will trigger. ![]() In order to disable the software watchdog, we just need to call the wdtDisable method on the ESP object, as indicated bellow.Īlthough this disables the software watchdog, the hardware watchdog will still remain active, causing a reset after some time. We can access the functionality of this class by using an extern variable called ESP, which is declared here in the libraries. In order to access the watchdog functions on the ESP8266, we have the EspClass, which can be analysed in more detail here. The board can also be bought at eBay here. The tests were performed using a NodeMCU board, a very cheap and easy to use ESP8266 board. ![]() The ESP8266 has 2 watchdogs, one implemented in hardware and another in software. Additionally, it is useful for problem in the code that may put the execution in an undesired infinite loop. This concept is of extreme importance, specially in microcontrollers, which may be affected by environmental conditions such as electrical noise, which can cause hardware malfunction that locks the execution. In those locking cases, the watchdog is not reset and, when it expires, resets the system. The watchdog should be configured with a time greater that the worst case scenario delay in the program, so it only triggers in error / unpredicted problems that may make the main program to be locked and not recover on its own. So, the main program needs to periodically reset the watchdog timer, to prevent the reset of the CPU and keep working normally. In our case, the system will be the ESP8266 microcontroller. The objective of this post is to analyse some of the watchdog functions available on the Arduino IDE libraries for the ESP8266.Ī watchdog is a timer that, when not reset before expiring, triggers the reset of the system that is monitoring.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |