Adafruit_SleepyDog icon indicating copy to clipboard operation
Adafruit_SleepyDog copied to clipboard

<Nano> If using without bootloader, wdt_reset stucks

Open Alan-NTHU opened this issue 6 years ago • 1 comments

I use with arduino Nano and upload with usbasp (ICSP), which means it is not programmed with a bootloader I think using other programmer that doesn't use the bootloader will also reproduce the problem.

Problem: After a first wdt_timeout , the nano hangs with crazy resetting (I use with apa102 led, so I see them showing my setup indicator repeatingly) , and reset button doesn't help, I would need to re-program the nano to get it work.

Later I found that by adding a clear flag of {MCUSR = 0;} just under "setup()// which a line found in <avr/wdt.h> and followed by a { Watchdog.disable();} can stop wdt_hanging after a wdt_reset. and program can run good again.

but {MCUSR = 0;} or {Watchdog.disable();}alone will not work, they are both needed and {MCUSR = 0;} should done first. I guess clearing the wdt reset flag (not sure if it is or not?) is very essential in this case.

please add this in your library, maybe like a Watchdog.begin() ? because it is a simple fix for users using ICSP, other fixes are pretty complex and I can't handle.

Alan-NTHU avatar Jun 13 '18 20:06 Alan-NTHU