The program had a loop that did something every second.
Now when I wanted to edit the program, I didn't succeed because the Pico booted over and over again and gave me no time to press Stop in Thonny and load my file to edit it.
Fortunately I could stop this by interrupting the I2C hardware and thus provoking an error.
I found a similar discussion already in the ESP part of the forum, concerning WEBREPL.
The outcome was that one should use longer watchdog intervals.
For the moment I'm using this:
Code: Select all
watchdog_time = 5000
def main():
wdt = WDT(timeout = watchdog_time)
#...
while True:
wdt.feed()
# emergency stop:
if stop_switch.value() == 0:
break
#...
time.sleep(1)
main()
There is only one caveit: After the program is interrupted correctly, the Pico boots once again, loses the connection to Thonny and shows the Micropython prompt after pushing the Stop/Restart button in Thonny.
For me the reason is that the watchdog is still running until reboot.
It would be fine if the watchdog could be deinitialized (I have read on pro and contra in the other forum topic), or is there another elegant way out of this?