-->
Page 1 of 2

How to execute while loops without Soft WDT Reset initiating

PostPosted: Wed Mar 13, 2019 2:46 am
by shejan0
Hello ESP8266 Forum,

I am using the ESP8266 Arduino Core, on a NodeMCU board (loaded Firmware), and I am having issues with the Software WatchDog (as explained by https://arduino-esp8266.readthedocs.io/en/latest/faq/a02-my-esp-crashes.html). I cannot use the ESP Exception Decoder, as I am missing xtensa-lx106-elf-gdb.exe for some reason.

Anytime I use a while loop, it always seems to incite the Software Watch Dog to reset. I currently have my code use the looping system of the void loop and using if statements. But I need to seriously use while loops in the future.

How do I execute while loops without inciting the WatchDog?

Re: How to execute while loops without Soft WDT Reset initia

PostPosted: Wed Mar 13, 2019 6:28 am
by rudy
Try putting delay(1) in the loop.

If that doesn't work then post your code.

Re: How to execute while loops without Soft WDT Reset initia

PostPosted: Wed Mar 13, 2019 7:32 am
by btidey
You can also normally avoid using extended while loops within the outer main loop by using state machines to determine what logic is executed.

A simple state machine just has a state variable which is tested in a switch statement. Each case then determines what to do and when to make a transition to another state.

This helps clarify the code logic and assists with keeping things like handleClient() regularly called from the main loop if required.

Re: How to execute while loops without Soft WDT Reset initia

PostPosted: Wed Mar 13, 2019 3:34 pm
by shejan0
btidey wrote:You can also normally avoid using extended while loops within the outer main loop by using state machines to determine what logic is executed.

A simple state machine just has a state variable which is tested in a switch statement. Each case then determines what to do and when to make a transition to another state.

This helps clarify the code logic and assists with keeping things like handleClient() regularly called from the main loop if required.


So you are saying to make variables and switch cases?