[En-Nut-Discussion] Timer2/watchdog timer

Alexander Baranov baranov at intech21.com
Fri Nov 5 16:19:35 CET 2004


Hi,
I don't see where do you reset the watchdog timer.

Maybe it's better to use standard modules?

wdt_enable(WDTO_2S)  - watchdog enable;
wdt_reset() - watchdog reset

Regards, Alexander

----- Original Message ----- 
From: "Sigurd Kleppan" <021243 at student.hit.no>
To: <en-nut-discussion at egnite.de>
Sent: Friday, November 05, 2004 9:47 AM
Subject: [En-Nut-Discussion] Timer2/watchdog timer


> 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();
> }
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>
>





More information about the En-Nut-Discussion mailing list