Microprocessor & Microcontroller: Unit - Iii Timer0 (Atmega8) Dr. J. Siva
Microprocessor & Microcontroller: Unit - Iii Timer0 (Atmega8) Dr. J. Siva
Microcontroller
Unit – III
Timer0(ATmega8)
Dr. J. Siva
1
8-bit Timer/Counter0
• Timer/Counter0 is a general purpose, single channel, 8-bit
Timer/Counter module
• The counting direction is always up (incrementing)
• The counter simply overruns when it passes its maximum
8-bit value (MAX = 0xFF) and then restarts from the
bottom (0x00)
• In normal operation the Timer/Counter Overflow Flag
(TOV0) will be set in the same timer clock cycle as the
TCNT0 becomes zero
• A new counter value can be written anytime
• Max delay time =
(Max. Count+1) × (1/Fosc ) × Prescale value =
Timer0 Block Diagram
Timer/Counter Control Register – TCCR0
Timer/Counter (TCNT0)
• Initial count =
Maximum count +1 - Required count = 255 + 1 – 200 = 56
Delay Calculation with Prescalar
• Required delay = 500 μs Fosc = 1 MHz
• Initial count =
Maximum count +1 - Required count = 255+1-62 = 194
= 0xC2