You are on page 1of 19

TOPICS TO COVER TODAY

1. Quick Revision
2. ATmega 32 : Timer & Counter Programming

1
2
3
TCCR: Timer/Counter Control Register
TOV: Timer Overflow
TCNT: Timer/Counter Register
OCR: Output Compare Register
OCF: Output Compare Flag
4
5
6
7
8
9
10
Question..
What would be the content of TCCR0 if you want to
run the counter in Normal mode with No
Prescaling?

11
Question..
What would be the content of TCCR0 if you want to
run the counter in CTC mode with external clock
source, clock activating on rising edge?

12
Question..
Find the timers clock frequency and its period for
various AVR-based system with the following clock
frequencies. Assume that no prescaler is used.

A. 10 MHz
B. 8 MHz
C. 1 MHz

13
Time Delay Calculations

Time delay = (FF NN + 1) x Single Clock Period

Where: FF = Biggest 8 bit Hex number


NN = Hex value to load in TCNT0

14
Time Delay Calculations

Time delay = (256 MM) x Single Clock Period

Where: MM = Decimal value to load in TCNT0

15
Question..
What value will you load into TCNTO if you want to
generate time delay of 25 uSec ? Assume Clock
frequency = 1 MHz, and no prescaling is used.

16
Question..
What value will you load into TCNTO if you want to
generate time delay of 1 uSec ? Assume Clock
frequency = 10 MHz, and no prescaling is used.

17
Steps For Programming

18
AVR: 8-bit Timer/Counter 0

19

You might also like