ArduinoLowPower icon indicating copy to clipboard operation
ArduinoLowPower copied to clipboard

One attachInterruptWakeup causes all interrupts to wake from deep sleep

Open trogper opened this issue 5 years ago • 7 comments

I have multiple standard arduino attachInterrupt calls and one LowPower.attachInterruptWakeup, however all interrupts cause the arduino to wake up, and none of them, if I have no LowPower.attachInterruptWakeup

trogper avatar Apr 26 '19 15:04 trogper

This line makes the interrupt wakeup capable https://github.com/arduino-libraries/ArduinoLowPower/blob/master/src/samd/ArduinoLowPower.cpp#L93 , but it's also called in the core itself (https://github.com/arduino/ArduinoCore-samd/blob/master/cores/arduino/WInterrupts.c#L80) so once EIC clock is not stopped during sleep every configured pin can wakeup the board. @cmaglie @sandeepmistry should we remove the wakeup setting from the core and leave it in the library only?

facchinm avatar Apr 29 '19 08:04 facchinm

@facchinm I think that line was added for people not using the low power lib: https://github.com/arduino/ArduinoCore-samd/pull/90

I'm ok with removing it, if you think it's best.

sandeepmistry avatar May 01 '19 16:05 sandeepmistry

What about breaking older projects/sketches, which "rely" on this bug and are not using LowPower.attachInterruptWakeup on all required pins?

trogper avatar May 01 '19 16:05 trogper

@trogper Can we include a warning at compile time?

sslupsky avatar May 08 '19 20:05 sslupsky

@sslupsky I personally have used this library only once, so I won't be affected by the change. How would you differentiate correct usage from incorrect? When would you show the warning? Always? Do Arduino users/programmers read warnings if the program compiles and works? (in other words: is warning appropriate?) Wouldn't warning bother people who use it correctly?

trogper avatar May 08 '19 23:05 trogper

Good points. Maybe the object can be changed so that when the method is called you specify which external interrupt is attached. The "default" can be "all"?

sslupsky avatar May 23 '19 03:05 sslupsky

whatever solution is chosen, proper documentation will fix all issues and questions, i think. another option would be to add an additional (optional) boolean parameter to attachInterrupt like standbyWakeupCapability or something like that. that way it stays in the core and is obvious to anyone who is attaching an interrupt.

mamama1 avatar Jun 14 '22 22:06 mamama1