Page 2 of 2
Re: Initialize watchdog timer from function
Posted: Wed Jun 29, 2022 9:35 am
by bulletmark
PM-TPI wrote: ↑Wed Jun 29, 2022 8:36 am
wdt = WDT(timeout=120_000) is run before wdt.feed()
No it's not.
Re: Initialize watchdog timer from function
Posted: Thu Jun 30, 2022 11:34 am
by PM-TPI
PM-TPI wrote: ↑Wed Jun 29, 2022 8:36 am
Note: start_up() is run before run_ing()
isn't the order...
a) wdt = WDT(timeout=120_000) to Initialize
then..
b) wdt.feed
Or do I have this backwards ?
Re: Initialize watchdog timer from function
Posted: Thu Jun 30, 2022 11:49 am
by bulletmark
The error you report here shows that `wdt.feed()` is being called at startup *before* `wdt = WDT(timeout=120_000)`.
Re: Initialize watchdog timer from function
Posted: Thu Jun 30, 2022 3:09 pm
by PM-TPI
Code: Select all
from machine import WDT
def start_up(): # This is run FIRST... init wifi ble etc
global wdt
other stuff....
wdt = WDT(timeout=120_000) # 2min
def run_ing(): # This is run AFTER start_up and is run every min.
global wdt
wdt.feed()
other stuff....
wdt.feed() is in... run_ing()
not start_up()
Re: Initialize watchdog timer from function
Posted: Thu Jun 30, 2022 3:33 pm
by karfas
PM-TPI wrote: ↑Thu Jun 30, 2022 3:09 pm
Code: Select all
from machine import WDT
def start_up(): # This is run FIRST... init wifi ble etc
global wdt
other stuff....
wdt = WDT(timeout=120_000) # 2min
def run_ing(): # This is run AFTER start_up and is run every min.
global wdt
wdt.feed()
other stuff....
wdt.feed() is in... run_ing()
not start_up()
Nobody cares how you name the functions where WDT() and wdt.feed() get called.
In your case, run_ing() is (obviously) called somewhere
before the Watchdog object instance (=wdt) gets created.
Also note that you
need to declare the global variable near the beginning of your file ("wdt = None" like in a previous post).