Tuesday, 6 October 2015

Generate a 1s delay using TIMER0 in ATMEGA32

#include <avr/io.h>
void delay();
int main(void)
{  
 DDRB=0xff;
    DDRA=0XFF;
PORTA=0XFF;
TCCR0=0X05;
 

  while(1)
    {
      delay();
 PORTA=PORTA^0xff; 

    }
}
void delay()
{int i;
for(i=0;i<7;i++)
    {    TCNT0=0Xf0;  
     
     while((TIFR&0x01)==0);
 TIFR|=0x01;
 }
}

No comments:

Post a Comment