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

Calling with SLEEP_FOREVER does not disable watchdog #121

Open
hallard opened this issue Apr 21, 2022 · 1 comment
Open

Calling with SLEEP_FOREVER does not disable watchdog #121

hallard opened this issue Apr 21, 2022 · 1 comment

Comments

@hallard
Copy link

hallard commented Apr 21, 2022

If for any reason (for example the application start/stop playing with watchdog while not in sleep mode) then a call to

LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

can have unexpected wake (depending on how app is coded), so in case of using SLEEP_FOREVER parameter calling powerDown() the function should disable the watchdog (just in case, and it does not hurt because this is exactly what we want to do)

	if (period != SLEEP_FOREVER)
	{
		wdt_enable(period);
		WDTCSR |= (1 << WDIE);
	}

should becomes something like that

	if (period == SLEEP_FOREVER)
	{
                // we don't want to be waked by the watchdog, so be 
                // sure to disable it by changing the config
                // This has been tried and works
                WDTCSR = _BV(WDCE) | _BV(WDE);
                WDTCSR = 0; 
                // but may be just following also
                // wdt_disable();
	}
        else 
        {

		wdt_enable(period);
		WDTCSR |= (1 << WDIE);
	} 
@LurkingKiwi
Copy link

This is a bad idea, because if the programmer DOES want the watchdog working as a watchdog (not a timer) he will wonder why it keeps turning off, and will have to edit the library

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