Ake,
Thanks for your comments.
I'm not sure if you want to hear this or not, but we've just put in
support for the watchdog. It worked first time, with no problems.
Code is below: two functions, one called as part of startup sequence,
the other called from a watchdog task that's scheduled every second.
If we spin in a loop locking out all other tasks, the system is reset
as expected.
Our system has several sources of interrupt enabled (both UARTs, I2C
etc.): it works regardless of what's happeneing elsewhere.
By the way, we use GCC 3.3.1 with -O2 to compile.
Regards
Brendan
=========================================
CODE STARTS HERE:
#define REG(addr) (*(volatile unsigned int *)(addr))
#define WDOG_BASE (0xE0000000)
#define WDOG_WDMOD (0xE0000000)
#define WDOG_WDTC (0xE0000004)
#define WDOG_WDFEED (0xE0000008)
#define WDOG_WDTV (0xE000000C)
/* define basic watchdog timeout value as 100 ms */
#define WATCH_TIMER_100MS (250000) /* 10 MHz / 4 is i/p clock */
/*
* Configure and start watchdog
*/
static
void watchdog_init(void)
{
/* set the watchdog timer constant */
REG(WDOG_WDTC) = WATCH_TIMER_100MS * (50); /* 5 seconds for now */
/* set mode to reset on underflow */
REG(WDOG_WDMOD) = 0x3;
/* feed watchdog to start it off */
REG(WDOG_WDFEED) = 0xaa;
REG(WDOG_WDFEED) = 0x55;
return;
}
/*
* Feed the watchdog to prevent us from being reset
*/
void HwWatchdogFeed(void)
{
/* write the magic sequence to keep the dog happy */
REG(WDOG_WDFEED) = 0xaa;
REG(WDOG_WDFEED) = 0x55;
return;
}
END OF CODE
========================================
--- In lpc2000@yahoogroups.com, "Ake Hedman, eurosource" <akhe@b...>
wrote:
>
> Thanks Brendan,
>
> This is the right approach surely. I'm at that state now and have
no
> other alternative then to back a bit and go through this "the right
> way". I just have myself to blame. Have used watchdogs for many
years on
> PIC, AVR and other processors and expected no problem there except
for
> the usual forgetting to feed it in certain places. Oh well it's my
first
> project on this processor family so this makes me learn useful
stuff
> just as you write (just a bit hard to appreciate that right now ;-
) ).
> Really need the watchdog to work in this application though so
there is
> no shortcut.
>
> I just debug using GPIO pins and one of the serial ports at the
moment
> so there is no emulator connected now.
>
> Thanks for your tips, suggestions and moral support. I report my
> findings back.
> /Ake
>
>
> brendanmurphy37 wrote:
>
> >
> > Ake,
> >
> > I can almost feel your frustration: we've all been there!
> >
> > I'm very interested in the outcome of this, as our own task for
next
> > week is to get the watchdog working on our own LPC2134-based
system.
> >
> > I'm a bit surprised that no one has volunteered some working code.
> > Surely someone out there is using this?
> >
> > Unfortunately, as we haven't got there yet, I've nothing specific
to
> > suggest, other than a general strategy of getting something simple
> > working first, and then building up to where you are. For example:
> >
> > 1. As simple as possible startup, initialisation (all peripherals
> > disabled, all interrupts off etc.) and an application that
> > initialises the watchdog and uses GPIO to signal what it's doing
(and
> > maybe reads to indicate whether or not the watchdog should be
fed).
> > In other words, the simplest possible program with a working
> > watchdog.
> >
> > 2. Same program, but with your normal initialisation and setup
code,
> > added incrementally. Still working?
> >
> > 3. Compare and contrast with your real application, particularly
in
> > how peripherals, interrupts etc. are managed.
> >
> > In other words, get something simple working first, and build up
from
> > there. It'll take time, but maybe less time then starting from a
> > larger system that doesn't work.
> >
> > Hopefully, somewhere along the line, all will become obvious.
> >
> > By the way, are you running your code using an emulator connected?
> > I've seen strange behaviour in the past with watchdogs enabled.
Try
> > running stand-alone, if you haven't done so already.
> >
> > As a final suggestion, based on what you say below, I'd look very
> > carefully at every location interrupts are enabled/disabled (at
the
> > peripheral level, at the VIC and at the CPSR). Also at your
startup
> > and IRQ dispatch code. Maybe the processor is resetting and re-
> > initialising stuff without you realising? maybe throwing an
exception
> > you haven't noticed?
> >
> > As a final comment: 'though no doubt it feels like it, it's not
time
> > wasted: you'll know way more about the watchdog and processor at
the
> > end of all this then when you started.
> >
> > Good luck!
> >
> > Brendan
> >
> >
> > --- In lpc2000@yahoogroups.com, "Ake Hedman, eurosource"
<akhe@b...>
> > wrote:
> > >
> > > WD story update
> > >
> > > I changed the code to have the watchdog raising an IRQ instead
of a
> > > RESET. I initialize stuff and then go in in a while loop.
> > >
> > > 1.) With interrupts enabled but no interrupt channel active this
> > will
> > > not trigger the watchdog. Why?
> > >
> > > 2.) With one of the interrupt channels active ( UART0 writing
some
> > > characters ) the watchdog works. Without a dog feed the
watchdog is
> > > triggered and with a feed it runs fine. However what I
initialize
> > WDTC
> > > with does to seem to matter. I always get about 4 ms period
when I
> > > toggle a pin in the WD interrupt (60MHz clock).
> > >
> > > Is this behaviour recognized by anyone? Please!
> > >
> > > BTW the chip is LPC2138
> > >
> > > /Ake
> > >
> > >
> > > dr_danish_ali wrote:
> > >
> > > > Ok Ake, here's my dumb suggestion:
> > > >
> > > > Try enabling the watchdog, but just to interrupt not reset?
> > > > You'll need an interrupt handler / VIC channel to do it - can
you
> > > > spare one?
> > > > That ISR need just raise a flag for now.
> > > >
> > > > Once the watchdog is fed and running happily, you might then
be
> > able
> > > > to enable resets on
> > > > it.
> > > >
> > > > Hope this helps,
> > > > Danish
> > > >
> > > > --- In lpc2000@yahoogroups.com, "Ake Hedman, eurosource"
> > <akhe@b...>
> > > > wrote:
> > > > >
> > > > > I am still trying to solve my problems with the watchdog.
> > > > >
> > > > > I have now scaled away most stuff of my application and can
see
> > that
> > > > the
> > > > > problem occurs when either of three interrupts occur
> > (UART0/UART1/I2C0)
> > > > > in the system. Without the watchdog everything works fine
but
> > if I
> > > > > enable the watchdog everything crashes. I have tried to just
> > enable and
> > > > > trig one of the interrupts in turn but the situation is the
> > same.
> > > > >
> > > > > I'm totally out of clues at the moment so any (also things
that
> > > > might be
> > > > > considered dumb) are very welcome.
> > > > >
> > > > > Regards
> > > > > /Ake
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > SPONSORED LINKS
> > > > Microprocessor
> > > > <http://groups.yahoo.com/gads?
> >
t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+mic
> > rocontrollers&w4=8051+microprocessor&c=4&s=93&.sig=tsVC-
> > J9hJ5qyXg0WPR0l6g>
> > > > Microcontrollers
> > > > <http://groups.yahoo.com/gads?
> >
t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+m
> >
icrocontrollers&w4=8051+microprocessor&c=4&s=93&.sig=DvJVNqC_pqRTm8Xq0
> > 1nxwg>
> > > > Pic microcontrollers
> > > > <http://groups.yahoo.com/gads?
> >
t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=P
> >
ic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=TpkoX4KofDJ7c
> > 6LyBvUqVQ>
> > > >
> > > > 8051 microprocessor
> > > > <http://groups.yahoo.com/gads?
> >
t=ms&k=8051+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pi
> >
c+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=1Ipf1Fjfbd_HVI
> > lekkDP-A>
> > > >
> > > >
> > > >
> > > > --------------------------------------------------------------
----
> > ------
> > > > YAHOO! GROUPS LINKS
> > > >
> > > > * Visit your group "lpc2000
> > > > <http://groups.yahoo.com/group/lpc2000>" on the web.
> > > >
> > > > * To unsubscribe from this group, send an email to:
> > > > lpc2000-unsubscribe@yahoogroups.com
> > > > <mailto:lpc2000-unsubscribe@yahoogroups.com?
> > subject=Unsubscribe>
> > > >
> > > > * Your use of Yahoo! Groups is subject to the Yahoo!
Terms of
> > > > Service <http://docs.yahoo.com/info/terms/>.
> > > >
> > > >
> > > > --------------------------------------------------------------
----
> > ------
> > > >
> > >
> > >
> > > --
> > > ---
> > > Ake Hedman (YAP - Yet Another Programmer)
> > > eurosource, Brattbergavägen 17, 820 50 LOS, Sweden
> > > Phone: (46) 657 413430 Cellular: (46) 73 84 84 102
> > > Company home: http://www.eurosource.se
> > > Kryddor/Te/Kaffe: http://www.brattberg.com
> > > Personal homepage: http://www.eurosource.se/akhe
> > > Automated home: http://www.vscp.org
> > >
> > >
> > >
> > > [Non-text portions of this message have been removed]
> > >
> >
> >
> >
> >
> >
> > ------------------------------------------------------------------
------
> > YAHOO! GROUPS LINKS
> >
> > * Visit your group "lpc2000
> > <http://groups.yahoo.com/group/lpc2000>" on the web.
> >
> > * To unsubscribe from this group, send an email to:
> > lpc2000-unsubscribe@yahoogroups.com
> > <mailto:lpc2000-unsubscribe@yahoogroups.com?
subject=Unsubscribe>
> >
> > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service <http://docs.yahoo.com/info/terms/>.
> >
> >
> > ------------------------------------------------------------------
------
> >
>
>
> --
> ---
> Ake Hedman (YAP - Yet Another Programmer)
> eurosource, Brattbergavägen 17, 820 50 LOS, Sweden
> Phone: (46) 657 413430 Cellular: (46) 73 84 84 102
> Company home: http://www.eurosource.se
> Kryddor/Te/Kaffe: http://www.brattberg.com
> Personal homepage: http://www.eurosource.se/akhe
> Automated home: http://www.vscp.org
>
>
>
> [Non-text portions of this message have been removed]
>Message
Re: Problem with watchdog
2005-12-08 by brendanmurphy37
Attachments
- No local attachments were found for this message.