-
Notifications
You must be signed in to change notification settings - Fork 146
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
Cannot get External ISR to wake from sleep to work #264
Comments
Not a clue, I have not worked with sleep on these parts, will look into this as part of #158 |
Though, one thing I would note is that your debug prints might not be giving you useful output there. Add a Serial.flush() before calling enableSleep() to ensure that it waits until it's printed everything before going to sleep. |
Added the Serial.flush() but no avail :-( This is the output I get:
Hope you (or someone else) comes up with a solution ... |
Uhmmm... just noticed what is likely the problem - You have set the button pin to INPUT, hence it would be expected to ick up ambient electrical noise from the environment and transition randomly. Set it to INPUT_PULLUP or use an external pullup. There is a word for such a "floating" pin connected to the input pin of an IC when the device is designed to make sense of said electronic noise: Antenna If you do have an external pullup, more debugging effort is required.... A start would be, maybe after the first conditional block, |
@SpenceKonde
Thank you for your great work on the tiny processors (where would we be without you)!! |
Oh... duh.... of course... In IDLE sleep mode, all interrupt sources will wake the part..... Including the millis timekeeping one... IDLE sleep mode is pretty useless, frankly... the useful ones are STANDBY and POWERDOWN. STANDBY is probably the good one for most applications (do you really care if you're using 1uA or 0.1uA, when the self-discharge rate of any real battery is at least an order of magnitude higher, probably 2?) Also, initial version was missing the INTFLAGS bit, which you also figured out.... |
Ok, did not know that. |
Also, don't do this:
Problems: What I'd probably do is, leave it disabled in setup, enable it in enterSleep() ( |
Don't immediately see why powerdown would be different here, hmm. |
Closing since problem is sorted now, powerdown issue on list for #158 |
@SpenceKonde Excuses for the confusion .. |
@SpenceKonde After reading these comments I would pose this question about using an external interrupt to wake from sleep: Is it true that only the LOW level interrupt trigger, applied to the interrupt pin, can bring the ATtiny-0-1 MCU out of SLEEP_MODE_PWR_DOWN, because all other external triggers require a clock, that is not available in this sleep mode, to be detected? |
No, that is not correct. All pins can wake the chip on "both edges" (ie on change - like classic AVR PCINT) as well as low level. Additionally, there are a small number of "fully asynchronous" pins (pins 2 and 6 in each port), marked on the included pinout images, which are capable of waking the chip on not only change or low level, but also on rising or falling edge. I mention it in passing here: https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/PinInterrupts.md One thing that is worth noting however about the fully asynchronous pins, is that if used for a normal interrupt (not just waking rom sleep; not sure how wake from sleep impacts this phenomenon; suggest someone who has time test it and report back :-P ) the fact that they will respond to events shorter than a system clock cycle means that they are far more sensitive to noise. I tripped over this a while back. |
Refer to table 16-3 in the datasheet (that's the number for the table on the 1614 and 3216 datasheets, at least) |
The whole thing is described in greater detail in chapter 16 of the datasheet; the same principles also apply to the megaAVR 0-series, tinyAVR 2-series and AVR Dx-series. |
@SpenceKonde |
Hi,
Trying to write a simple sketch to attach a button to PA1, go to sleep after 10 seconds and then wait for button to be pressed to wake up again ...
I cannot get it to work.
What am I doing wrong?
The text was updated successfully, but these errors were encountered: