Tuesday, 27 October 2015

TIMER1 OVERFLOW VECTOR INTERRUPT (ATMEGA32)

Blink a port when an overflow occurs

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

ISR(TIMER1_OVF_vect){

TCNT1H=0XA0;
TCNT1L=0X00;
PORTA=0XFF;
_delay_ms(1000);
PORTA=0X00;
TIFR|=0x04;
}
int main(void)
{
    DDRA=0XFF;
SREG=0X80;
//TCCR1A=0x00;
TCCR1B=0X05;
TIMSK=0X04;

TCNT1H=0XA0;
TCNT1L=0X00;

while(1);

}

No comments:

Post a Comment