Skip to content

How to put Sleep and Wakeup MCU ATTiny804 for Optimizing Power Consumption of the Circuit? #1088

Answered by hmeijdam
krishank652 asked this question in Q&A
Discussion options

You must be logged in to vote

You can't set 5sec with the PIT. 1 sec is the longest you can set it to.

But you can put Tiny to sleep 5 times for one second like how I adapted the example below.

#include <avr/sleep.h>

void RTC_init(void)
{
  /* Initialize RTC: */
  while (RTC.STATUS > 0)
  {
    ;                                   /* Wait for all register to be synchronized */
  }
  RTC.CLKSEL = RTC_CLKSEL_INT32K_gc;    /* 32.768kHz Internal Ultra-Low-Power Oscillator (OSCULP32K) */

  RTC.PITINTCTRL = RTC_PI_bm;           /* PIT Interrupt: enabled */

  RTC.PITCTRLA = RTC_PERIOD_CYC32768_gc /* RTC Clock Cycles 32768, resulting in 32.768kHz/32768 = 1Hz */
                 | RTC_PITEN_bm;                       /* Enab…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@krishank652
Comment options

@hmeijdam
Comment options

Answer selected by krishank652
@krishank652
Comment options

@hmeijdam
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants