Timer/Counter – Overflow

  #include<avr/io.h>
  #include<avr/interrupt.h>
  uint8_t sample=0;
int main(void)
  {
   DDRD=0xFF;
   TCCR1A=0;							//since no source require
   TCCR1B=(1<<CS11);					//normal operation with 8 presaling
   TCNT1=0;							    //initialize timer1
   sei();								//set global interrupt
   TIMSK=(1<<TOIE1);					//set overflow interrupt
  while(1);
return 0;
}
ISR(TIMER1_OVF_vect)
{
 sample++;
 if(sample>=15){
		PORTD^=0x0F;
		sample=0;
	}
}

  #include<avr/io.h>
  uint8_t sample=0;
int main(void)
  {
   DDRD=0xFF;
   TCCR1A=0;						//since no source require
   TCCR1B=(1<<CS11);				  //normal operation with 8 presaling
   TCNT1=0;							//initialize timer1
  while(1)
    {
     if(TIFR&(1<<TOV1)){
        sample++;
        if(sample>=15){
		  PORTD^=0x0F;
		  sample=0;
	     }
    TIFR|=(1<<TOV1);
     }
    }
 return 0;
 }