Very long sleep possible? #413
-
Hi, So I went through sleep modes pages and code examples but I feel like I am missing a piece to make the device sleep for long time (like 1+ hours). Using the 1K clock and biggest period RTC_PERIOD_CYC32768_gc , I can achieve like 32second maximum. What is the obvious thing I am currently missing ? thank you ! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
Did you change the prescaler as well? Maximum prescaler is RTC_PRESCALER_DIV32768_gc, but looks like yours is set to RTC_PRESCALER_DIV1_gc. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the code examples. A future version of the core which addresses the longstanding issue #158 will add a library tentatively called SleepLib. which would have the following features:
|
Beta Was this translation helpful? Give feedback.
-
What the heck is this sorcery? I got an email about a reply here, with a screenshot of a figure from the datasheet that I'm kind of confused by. The words in the datasheet imply that the prescaled clock is what gets counted by the PIT, but I'm not sure how that timing diagram doesn't show the opposite, which would make it inaccurate. Example 23-1. PIT Timing Diagram for PERIOD = CYC16 This diagram unambiguously shows the prescaled clock going to the PIT Figure 23-2. Timing Between PIT Enable and First Interrupt But this one says that the PIT that the PIT is derived from the state of the RTC prescaler, not something attached Do note also that the ATtiny 0-series and 1-series (except with rev C 1-series parts with 32k of flash), have some very mean chameleon hornets nesting behind the CTRLA registers, try to avoid using impacted parts if you need the RTC, and if you must, you must never turn on the RTC without also turning on the PIT before any further interaction with the peripheral. As long as you do that, you'll be fine, as long as you don't touch RTC.CTRLA. If you do, the hornets still get one chance to sting you every time you write to it, resetting the current RTC period. When they finally fix that, it's gonna be a fuckin shitshow. I guarantee you there will be multiple instances of devices in mass production that didn't realize that was a bug, or even that something else wasn't resetting it (nothing is supposed to short of a reset or turning off the PIT), or completely misapprehended how the PIT works (I went back and forth with someone for days before it was made plain that they expected to be able to set the delay, go to sleep, and have the pit wake them that many second later. Uh, sorry, nope, not on the menu, not on those parts or any other AVRs. You can have the RTC wake you like that, but he wanted to use power down sleep mode. Thinking about it - it has to be that he didn't know that the only thing about standby sleep unchanged since classic AVRs is the name - it used to be something a little lower power than IDLE, but only a little, because the main power hog at that point is the oscillator - which it explicitly keeps on to eliminate the startup time of an external crystal; that was it's only purpose. Now it's an omnibus deeper-than-idle-less-deep-than-power-down mode, which can be tuned to anything from being lit up like a christmas tree, sucking down near-IDLE current, or you can leave everything off and it's nearly identical to power-down. |
Beta Was this translation helpful? Give feedback.
Did you change the prescaler as well? Maximum prescaler is RTC_PRESCALER_DIV32768_gc, but looks like yours is set to RTC_PRESCALER_DIV1_gc.