Just a minor point, the newer range of AVR devices , (atmega168, xmega etc) have the capability of mapping the watchdog timeout to an interrupt rather than a reset, therfore breadcrumbs can be managed.
2 methods spring to mind with watchdogs,
1) The dark art of assertion Macros, these can prove inavluable in determining a porblem area of code.
2) Just before you "Tickle/Kick" the watchdog include a routine for writing a value to an eeprom area a bytye should do it, if his is a different value for each area of code then the value could be read on reset and a deduction made about which areaa of code caused the problem, his would add little latency, although would degrade the eeprom life, it could be implemented in debug only.
How do you intent to deal with the watchdog reset after the code has been implemented as a product ? Do you record, inform, analyse or just let it resert and hope no one notices.
Are you using any real time time ? Context switching and re entrancy can prove a real nightmare to debug.
Common steps for RTOS systems are
1) Build a watchdog task which is the only part of the software that is allowed to tickle the watchdog.
2) Create a data structure that has one entry / task. Whenever a task starts it increments this entry.
3) Increment the data "atomically".
4) Assess how many times/ sec a task "should " run, create min/max values for the data structure for each tasks, that way if a "spurious" number is detected allow the system to time out.
This way you will get "a feel" for how the system really works, bottle necks etc and you adjust accordingly.
And remeber the best watchdog of all is theone that is external to the system and does not rely on software, external to the CPU and shares no resources.
Think carefully on how / what you are using/abusing the watchdog, it may give you more problems than it solves.
Regards
--- In AVR-Chat@yahoogroups.com, Jim Wagner <wagnerj@...> wrote:
Show quoted textHide quoted text
>
> Chuck -
>
> My experience is that a watchdog timer is simply a reset of last
> resort, after the horses are out of the barn, but hopefully before
> they have wandered to some place dangerous. I know of no way to read
> the watchdog timer. You only know when it has timed out.
>
> I personally don't try to keep a bread crumb trail. I'm just thankful
> that it got reset. I have not had a known watchdog reset in recent
> history or ever with an AVR so I don't know what I would do. Of
> course, that does not mean that my next project will be so fortunate!
> Or, the one after that.
>
> Jim Wagner
> Oregon Research Electronics.
>
> On Jul 20, 2009, at 7:52 PM, Chuck Hackett wrote:
>
> > I am about to use the WDT for the first time (ATMega16). I do not
> > have a
> > software problem in my device at the moment but I want to have the WDT
> > active in my production application.
> >
> > From reading the full datasheet for the ATMega16 it seems that,
> > after a WD
> > reset, there is no way to determine what the value of the Program
> > Counter
> > was at the time.
> >
> > So how does one record information to determine where the bug might
> > be in a
> > situation where it is very difficult to reproduce the conditions
> > that caused
> > the software hang?
> >
> > I can have the application leave 'breadcrumbs' at different points
> > but this
> > would either take a lot of time to narrow in on or take a lot of
> > 'breadcrumb' code.
> >
> >
> >
>
>
>
> [Non-text portions of this message have been removed]
>