Вы находитесь на странице: 1из 26

1

Steps For Programming

TCCR0 = 0;

2
3
4
How To Clear TOV0 ?

To clear any flag, write logic 1 to it.

Yes, it is strange, but it is how it works with AVR !!

5
TIMER0 Used As Counter

6
7
8
TOPICS TO COVER TODAY

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

9
Question..
Assume that a 1Hz clock pulse is fed into TO (PB0),
write a program to count these pulses on falling
edge and display the state of TCNT0 count on
PORTC.

10
CTC Mode: Compare-Match mode

11
12
Question..
Write a C Program to generate a square wave of
time period 150 uSec on Pin 1 of Port A. Assume
Crystal Frequency = 1 MHz. Use Timer in CTC
mode.

13
Difference Between TIMER0 and TIMER2

Timer2 can be used as real time counter.


To do so ::
1. connect a crystal of 32.768 kHz to the TOSC1
and TOSC2 pins of AVR
2. Set AS2 bit in ASSR Register

14
15
16
17
Timer 1

18
19
16 Bit Register : Split Into Two 8-bit Reg.

20
21
22
23
24
25
26

Вам также может понравиться