Академический Документы
Профессиональный Документы
Культура Документы
LAB 5
Handling Timers with interrupts on Atmega 32
Objectives
•Learning the use of timers
•Introduction interrupts of Atmega 32 processor
•Learning basics of Atmel studio
•Learning use of timers with interrrupts 32 processor
Tools Used
•Proteus 8.0
•Atmel Studio 7.0
BSCS 4-A Burhan Ahmed Satti 01-134172-065
int Counts = 0;
DDRB = 1<<7;
TCCR0 = 1<<WGM01;
OCR0 = 25;
TIMSK = 1 << OCIE0;
sei();
TCCR0 = 1 << CS00;
while(1)
{
}
}
ISR(TIMER0_COMP_vect)
{
Counts++;
if(Counts >= 100)
{
Counts = 0;
PORTB ^= 1<<7;
TCNT0 = 0;
}
}
Result
Conclusion
The LED toggles every half second.
int Counts = 0;
DDRB = 1<<7;
TCCR0 = 1<<WGM01;
OCR0 = 25;
TIMSK = 1 << OCIE0;
sei();
TCCR0 = 1 << CS02;
while(1)
{
}
}
ISR(TIMER0_COMP_vect)
{
Counts++;
if(Counts >= 39.0625)
{
Counts = 0;
PORTB ^= 1<<7;
TCNT0 = 0;
}
}}
Result
Conclusion
LED is toggling successfully.