On the off chance that the internet needs more sleep examples, and because I wanted to play with GitHub Gists:https://gist.github.com/JChristensen/5616922
Thanks - that looks far more complete (and complicated) than the one I have already seen.
I do not understand what some of the BOD code is doing, but based on your comments, you turn BOD off for sleeping - but I didn't see any code to turn it back on again. Does that happen by default?
Writing to the BODS bit is controlled by a timed sequence and an enable bit, BODSE in MCUCR. To disable BOD inrelevant sleep modes, both BODS and BODSE must first be set to one. Then, to set the BODS bit, BODS must beset to one and BODSE must be set to zero within four clock cycles.The BODS bit is active three clock cycles after it is set. A sleep instruction must be executed while BODS is activein order to turn off the BOD for the actual sleep mode. The BODS bit is automatically cleared after three clockcycles.
That makes sense to me, thanks.I am curious - how much time does it take from Interrupt detected to wake the Arduino up? Would a human notice any lag, if the switch they were pressing was generating the Interrupt and they expected an instantaneous response to the button press? Where instantaneous is human-reaction time based, not electronic.
Just tested your sleep_ATtinyX5.ino on a ATtiny13.It worked wothout any changes !I can't even measure the current when it is in sleep (cheap multimeter)One thing that is strange:I have to toggle pin PB1, which according to the datasheet is PCINT1 and not PB0 which is PCINT0Thanks for sharing
But it should wake as soon as the pin is driven low, toggling it (low then high) should not be necessary.
I see in the datasheet that INT0 is PB1 (DIP pin 6)
Are you using the Arduino-Tiny core with the '13?
I am using Smeezekitty's core. As far as I know the Arduino-Tiny core does not support ATtiny13.Smeezekitty's core:http://forum.arduino.cc/index.php?topic=89781.0
Hi Jack, this is great stuff! How do you wake up the MCU when INT0 is on high?
Thank you! I am using the ATTiny45. I used a pin change interrupt to wake it up. Akshay