[En-Nut-Discussion] Timer2/watchdog timer

Sigurd Kleppan 021243 at student.hit.no
Fri Nov 5 15:47:26 CET 2004


Hey!

I have written code to run Timer2. When the timer overflow, a interrupt runs. This works, but the the Wathdogtimer restarts the board. 
Does Timer2 affect The Watchdog Timer?

Thank you!

Regards
Sigurd Kleppan


void run_watchdog(){
 for(;;) { 
  NutEnterCritical();    //kjører koden i sikkert modus uten interrupt
  WDTCR = 0x18; 		 //initialiserer
  WDTCR = 0x0F; 		 //starter watchdog og setter timer til 1.9s.
  NutExitCritical(); 
  NutSleep(100); 
  //printf("%d",inp(WDTCR));
  NutEnterCritical(); 
  WDTCR = 0x18; 
  WDTCR = 0;		  	 //avslutter Watchdog timer
  NutExitCritical(); 
 } 		
}	



#pragma interrupt_handler	timer0_handler:11  //timer2 when overflow
void timer0_handler(void)
	{	
	timer=timer+1;
	if (timer==100){
	 printf("5");	
	 timer=0;
	 }
    }


main(){
//Timer2
 TCCR2 = BV(CS22) | BV(CS20); 
 TIMSK = BV(TOIE2);
 TIFR  = BV(TOV2);
 run_watchdog();
}




More information about the En-Nut-Discussion mailing list