I'm having trouble understanding the datasheets for the ATtiny and I need to know what is the largest prescaler that can be set for an ATtiny Timer Interupt? I'm new to hardware so can someone tell me if this is correct:

void setupInterupt()
  TCCR2A = 0;                       
  TCCR2B = 0;                       
  TCNT2 = 0;                        
  OCR2A = PERIOD - 1;               
  TIMSK2 = _BV(OCIE2A);             
  TCCR2B |= _BV(CS13) | _BV(CS12) | _BV(CS12) | _BV(CS10);  

Will this set a prescaler of 16384? Am I understanding the chart on page 89 correctly and is my syntax okay? This is my first Arduino Project.

  • You're using the registers for timer 2, which that chip doesn't have. Also, you're using CS12 twice. Jun 18, 2016 at 17:23
  • So I only have Timer 1? I guest that limits the kind of sleep mode I can use since the power saver mode turns Timer 1 off. Jun 18, 2016 at 17:38
  • 1
    Please clarify what you are trying to do with the timer. Short answer, looking, yes it does set a prescaler of 16384, that stuff is for the PWM stuff. Please clarify the your clock frequency and what you plan to do with the timer? Thanks
    – RSM
    Jun 18, 2016 at 17:40
  • The ATtiny85 doesn't have Power-save mode, only Idle, ADCNR, and Power-down. Jun 18, 2016 at 17:42
  • 1
    Why not just use the watchdog to wake? Jun 18, 2016 at 23:35

1 Answer 1


I don't know the objectives of your project, or its constraints and requirements. Thus, portions of the following might not apply.

If I were using an ATtiny85 in an application that needed to “maximize the amount of power saved” and also needed to wake up about every 33 ms, I'd use the factory-calibrated 8 MHz clock (rather than attaching a 20 MHz external crystal), and use system clock prescaling [see §6.3, System Clock Prescaler, on page 31 of the ATtiny85 specs, and Table 6-15. Clock Prescaler Select, p. 33] to scale that 8 MHz down to 250 KHz. As implied by Table 21-1, DC Characteristics, page 162 of specs, this will drop CPU current draw down to under 0.1 mA if powered by 2 V, or under 0.35 mA if powered by 3 V.

With the system clock running at 250 KHz, you can use timer 0 prescaled by a factor of 1024 [see §11.3.1, Internal Clock Source with Prescaler, p. 166 of specs] to get an interrupt every 33 ms or so.

If 250 KHz is too slow to get done with whatever computation needs to be done every 33 ms, upon waking I would change the system clock prescale factor per §6.3.1, Switching Time, to 8 MHz or 4 MHz or whatever it needs to be to get the computation done at lowest power cost. That might or might not be the same as getting the computation done most quickly.

Then, after the periodic computation is done, I'd revert the system clock to 250 KHz, and go to sleep in Idle mode (Ref §7.1.1, Idle Mode) with almost everything except timer 0 shut down via the PRR. (Ref §7.3, Power Reduction Register.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.