[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Watchdog


The watchdog causes a NMI if you don't feed it at
least once each 0.1 seconds. It then resets the Etrax
if you don't feed it within 3.3ms after the NMI.

This means that you have to feed the watchdog
periodically if it is running for more than 0.1 second.
This can e.g. be achieved by feeding it in the timer

Note that I haven't actually tested the code below 
on elinux but it works with another OS running on

The following example code enables the watchdog:
/* Allow watchdog interrupts */
#include <asm/svinto.h>

*R_IRQ_MASK0_SET = IO_STATE(R_IRQ_MASK0_SET, watchdog_nmi, set);
/* Start watchdog */
__asm__ volatile ("setf m"); /* Enable nmi */
*R_WATCHDOG = IO_FIELD(key, watchdog_key) |
              IO_STATE(enable, start); /* Start watchdog */

The following code can be used to feed the dog:

static byte   watchdog_key = 0;

void feed_watchdog(void)
  watchdog_key = ~watchdog_key;
  *R_WATCHDOG = IO_FIELD(key, watchdog_key & 0x07) |
                IO_STATE(enable, start);

kill dog:

void stop_watchdog(void)
  *R_WATCHDOG = IO_FIELD(key, (~watchdog_key) & 0x07) |
                IO_STATE(enable, stop);

If you want to know the point of execution when the NMI happened
you can use the following:

void watchdog_starving(udword interrupt_address)
  stop_watchdog(); /* Kill dog so it won't bother us again */
  printf("*** WATCHDOG IS STARVING ***\r\n");
  printf("called from %X\r\n", interrupt_address);

and in the interrupt handler (in elinux lagnuage NMI uses
interrupt number 1):

  move brp, r10                   ; Address where we got interrupted
  jsr  _watchdog_starving

This was a lot lowlevel stuff. Hope it helps! 

Best Regards

-----Original Message-----
From: owner-dev-etrax@xxxxxxx.com]On">mailto:owner-dev-etrax@xxxxxxx.com]On
Behalf Of Nikolaus H. Krug
Sent: Wednesday, November 15, 2000 10:29 AM
To: dev-etrax
Subject: Watchdog

Hi there!

For my program I've to use the on-board-watchdog. Can anyone tell me how to
use it at C/C++ or better send me a URL where I can read about it?
thanks a lot