2016-06-07 17:46:27 -04:00
|
|
|
.. currentmodule:: machine
|
2017-04-18 01:27:37 -04:00
|
|
|
.. _machine.WDT:
|
2015-06-10 17:29:56 -04:00
|
|
|
|
|
|
|
class WDT -- watchdog timer
|
|
|
|
===========================
|
|
|
|
|
|
|
|
The WDT is used to restart the system when the application crashes and ends
|
|
|
|
up into a non recoverable state. Once started it cannot be stopped or
|
2015-10-14 06:32:01 -04:00
|
|
|
reconfigured in any way. After enabling, the application must "feed" the
|
2015-06-10 17:29:56 -04:00
|
|
|
watchdog periodically to prevent it from expiring and resetting the system.
|
|
|
|
|
|
|
|
Example usage::
|
|
|
|
|
2015-10-20 10:24:25 -04:00
|
|
|
from machine import WDT
|
|
|
|
wdt = WDT(timeout=2000) # enable it with a timeout of 2s
|
2015-09-13 11:06:12 -04:00
|
|
|
wdt.feed()
|
2015-06-10 17:29:56 -04:00
|
|
|
|
2022-08-22 02:09:02 -04:00
|
|
|
Availability of this class: pyboard, WiPy, esp8266, esp32, rp2040, mimxrt.
|
2016-08-17 00:22:39 -04:00
|
|
|
|
2015-06-10 17:29:56 -04:00
|
|
|
Constructors
|
|
|
|
------------
|
|
|
|
|
2016-06-08 20:03:53 -04:00
|
|
|
.. class:: WDT(id=0, timeout=5000)
|
2015-06-10 17:29:56 -04:00
|
|
|
|
2020-05-02 03:17:54 -04:00
|
|
|
Create a WDT object and start it. The timeout must be given in milliseconds.
|
|
|
|
Once it is running the timeout cannot be changed and the WDT cannot be stopped either.
|
2021-12-14 19:49:22 -05:00
|
|
|
|
2020-05-02 03:17:54 -04:00
|
|
|
Notes: On the esp32 the minimum timeout is 1 second. On the esp8266 a timeout
|
2022-08-22 02:09:02 -04:00
|
|
|
cannot be specified, it is determined by the underlying system. On rp2040 devices,
|
|
|
|
the maximum timeout is 8388 ms.
|
2015-06-10 17:29:56 -04:00
|
|
|
|
|
|
|
Methods
|
|
|
|
-------
|
|
|
|
|
2021-09-26 17:14:56 -04:00
|
|
|
.. method:: WDT.feed()
|
2015-06-10 17:29:56 -04:00
|
|
|
|
2015-09-13 11:06:12 -04:00
|
|
|
Feed the WDT to prevent it from resetting the system. The application
|
2015-06-10 17:29:56 -04:00
|
|
|
should place this call in a sensible place ensuring that the WDT is
|
2015-09-13 11:06:12 -04:00
|
|
|
only fed after verifying that everything is functioning correctly.
|