Watchdog with interup program, can i use watchdog?

Code tips and tricks for beginners
Post Reply
Helmut_number_one
Posts: 149
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 93 times
Been thanked: 17 times

Watchdog with interup program, can i use watchdog?

Post by Helmut_number_one »

Can't i use a watchdog in a program with an interrupt program and "wait" in the code?
If so, what do I have to write?
User avatar
cicciocb
Site Admin
Posts: 2626
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 549 times
Been thanked: 1861 times
Contact:

Re: Watchdog with interup program, can i use watchdog?

Post by cicciocb »

The logic of the Watchdog is to put inside a loop that execute the main code.

In your case, if your program "waits", you could use a timer like this :

Code: [Local Link Removed for Guests]

.....
timer0 5000, myWDT ' set a timer each 5 seconds
OPTION.WDT 10000 ' set the timeout at 10 seconds
.....
...

WAIT

myWDT:
OPTION.WDTRESET
return
Helmut_number_one
Posts: 149
Joined: Fri Dec 09, 2022 10:03 am
Has thanked: 93 times
Been thanked: 17 times

Re: Watchdog with interup program, can i use watchdog?

Post by Helmut_number_one »

Great, otherwise I always have to turn off the voltage using a fuse in the house when the ESP32 C Mini crashes ;-(
Thank you for the code.
Post Reply