tags:

views:

152

answers:

7

Can Anyone tell me whether we should enable or disable watch dog during the startup/boot code executes?My friend told me that we usually disable watch dog in the boot code. Can anyone one tell me what is the advantage or disadvantage of doing so??

+3  A: 

It really depends on your project. The watchdog is there to help you ensure that your program won't get "stuck" while executing code. -- If there is a chance that your program may hang during the boot-procedure, it may make sense to incorporate the watchdog there too.

That being said, I generally start the watchdog at the end of my boot-up procedures.

Nate
A: 

Fewer transistors switching, I suppose, so minuscule power savings. Depending on how much you sleep, this might actually be a big savings. Your friend might be referring to the practice of turning off the WDT when you're actually doing something, then turning it on when you sleep. There's a nice little point that Microchip gives about their PICs:

"If the WDT is disabled during normal operation (FWDTEN = 0), then the SWDTEN bit (RCON<5>) can be used to turn on the WDT just before entering Sleep mode"

Rooke
+2  A: 

Usually the WD (watchdog) is enabled after the boot-up procedure, because this is when the program enters its "loop" and periodically kicks the WD. During boot-up, by which I suppose you mean linear initialization of hardware and peripherals, there's much less periodicity in your code and hard to insert a WD kicking cycle.

Eli Bendersky
+1  A: 

I always have it enabled. What is the advantage of disabling it? So what if I have to reset it during the bootup code?

Jeanne Pindar
+2  A: 

Production code should always enable the watchdog. Hobby and/or prototype projects are obviously a special case that may not require the watchdog.

If the watchdog is enabled during boot, there is a special case which must be considered. Erasing and writing memory take a long time (erasing an entire device may take seconds to complete). So you must insure that your erase and write routines periodically service the watchdog to prevent a reset.

Tim Henigan
+1  A: 

If you're debugging, you want it off or the device will reboot on your when you try to step through code. Otherwise it's up to you. I've seen watchdogs save projects' butts and I've seen watchdogs lead to inadvertent reboot loops that cause customers to clog up the support lines and thus cost the company a ton.

You make the call.

Southern Hospitality
+1  A: 

The best practice would be to have the watchdog activate automatically on power up. If your hardware is not designed for that switch it on as soon as possible. Generally I set the watchdog up for long duration during bootup but once I am past boot up I go for a short time out and service the watchdog regularly.

You might not always be around to reset a board that hanged after a plant shut down and restart at a remote location. Or the board is located in a inaccessible basement crawl space and it did not restart after a power dip. Lab easy practices is not real world best practices.

Try and design your hardware so that your software can check the reset cause at bootup and report. If you get a watchdog timeout you need to know because it is a failure in your system and ignoring it can cause problems later.

It is easier to debug with the watchdog off but during development regularly test with the watchdog on to ensure everything is on track.

Gerhard