Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<Nano> If using without bootloader, wdt_reset stucks #14

Open
Alan-NTHU opened this issue Jun 13, 2018 · 1 comment
Open

<Nano> If using without bootloader, wdt_reset stucks #14

Alan-NTHU opened this issue Jun 13, 2018 · 1 comment

Comments

@Alan-NTHU
Copy link

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.

@ermtl
Copy link

ermtl commented Nov 24, 2018

The problem also happens in Nanos with a bootloader that does not clear the watchdog settings. I made a patch that solves the issue by issuing a soft reset instead of a hard reset.

The way to use it is to specify a negative number in the Watchdog.enable parameter.
(works with the BasicUsage.ino example)
Watchdog.enable(-4000);

https://github.com/ermtl/Adafruit_SleepyDog/tree/ermtl-softReset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants