watchdog and lightsleep
Posted: Sun Aug 07, 2022 6:58 pm
ok the watchdog can't be longer than 8.3 seconds. This is a problem if you want to do lightsleep and having the watchdog just in case that the cpu hang.
For this reason I create a loop of lightsleep to go around it.
For this reason I create a loop of lightsleep to go around it.
Code: Select all
wdt = machine.WDT(timeout=8300000)
# define lightsleep with watch dog limits
# because we implemented wachtdog we need to
# maximize the light sleep to be lower than 8 second
# the watch dog is 24 bits at 1us clock by a count of 2
# then the maximum is (2**24 -1)/2 which is ~8.3 sec
# we will use 5 seconds step
def wd_lightsleep(value):
if WatchDog_Enable:
while value >0:
if value >= 5000:
machine.lightsleep(5000)
value = value - 5000
else:
machine.lightsleep(value)
value=0
wdt.feed()
else:
machine.lightsleep(value)