8-bit AVR Microcontroller

Asynchronous Operation of Timer/Counter2

When Timer/Counter2 operates asynchronously, some considerations must be taken.

  1. 1.Disable the Timer/Counter2 interrupts by clearing OCIE2 and TOIE2.
  2. 2.Select clock source by setting AS2 as appropriate.
  3. 3.Write new values to TCNT2, OCR2, and TCCR2.
  4. 4.To switch to asynchronous operation: Wait for TCN2UB, OCR2UB, and TCR2UB.
  5. 5.Clear the Timer/Counter2 Interrupt Flags.
  6. 6.Enable interrupts, if needed.
  1. 1.Write a value to TCCR2, TCNT2, or OCR2.
  2. 2.Wait until the corresponding Update Busy Flag in ASSR returns to zero.
  3. 3.Enter Power-save or Extended Standby mode.
  1. 1.Write any value to either of the registers OCR2 or TCCR2.
  2. 2.Wait for the corresponding Update Busy Flag to be cleared.
  3. 3.Read TCNT2.