Help in using the watchdog effectively

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

I have a basic program, where its main thread does some initialization and ends up in an infinite empty loop.

There is one interrupt which multiplexes the 7 segment led, and one external port interrupt for data.

How do I use the watchdog effectively in this case?

Also, any good links to resources which explain good usage of watchdogs?

Thanks,
Aakash

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

ends up in an infinite empty loop

Interesting. I've envisioned apps like this, but never actually did one. And my normal apps are the opposite--nearly the whole app in the main loop.

(Why? Let's say you get several "data" interrupts and it takes some time to service then--you could lose info, or get out of sync, more likely than capturing the data and "queuing" it for processing. But that is another philosophical discussion.)

In your main loop, do the WDR based on all critical conditions happening. First, your main loop is running. ;) Second, set a flag in the multiplex ISR and then in the main loop you "know" that timers are running and interrupts are firing.

The incoming data is a little trickier--if it is unsolicited then it really isn't a candidate for WD conditions. I have several apps where I require my remote AVR "slaves" to be polled by the AVR "master" within a relatively short period of time; otherwise they watchdog. This prevents any slave that runs amok from holding the RS485 and preventing comms.

while (1)
   {
   if (mux_flag)
      {
      mux_flag = 0;
      #asm ("wdr")
      }
   }

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Aak wrote:
How do I use the watchdog effectively in this case?

Simple disable it.

There is no constraint, that every peripheral inside a micro must be used.

Or was your application dangerous (power plant, aeronautics, medicine)?

Peter