EmbeddedRelated.com
Forums

Problem with watchdog

Started by Ake Hedman, eurosource December 6, 2005
Hi all.

I am trying to enable the watchdog but the result is a total hang of the
board. Not even the bootloader is possible to reach after the crash and
I have to reapply power with P0.14 low to get access to the botloader
again. Reset is not enough.

The code to initialize the watchdog is

// initialize the watchdog timer
WDTC = 0xffffffff; // 15000000; // One second
= 15000000
WDMOD = WDEN | WDRESET; // Activate watchdog
WDFEED = 0xAA; WDFEED = 0x55;

I must have misunderstood the WD functionality. What am I doing wrong?
In the above code the watchdog should not trigger until 5 minutes
elapsed so even if a vector should be wrong the code that follow should
run for a while but as soon as I write to the WDMOD register I get a hang.

/Ake

--
---
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


An Engineer's Guide to the LPC2100 Series

Assuming you have the correct definitions for your symbols, the only thing I
can think of is setting the timeout to the largest integer like that. Maybe
you could try a different large integer?

These are what you should be using:
WDEN = BIT(0) = 0x00000001
WDRESET = BIT(1) = 0x00000002
WDMOD = (uint8_t *)(0xE0000000)
WDTC = (uint32_t *)(0xE0000004)
WDFEED = (uint8_t *)(0xE0000008)

----------------------
Jim Parziale
Email: nuncio.bitis@nunc...
Malden, MA
----------------------

On 12/6/05, Ake Hedman, eurosource <akhe@akhe...> wrote:
>
> Hi all.
>
> I am trying to enable the watchdog but the result is a total hang of the
> board. Not even the bootloader is possible to reach after the crash and
> I have to reapply power with P0.14 low to get access to the botloader
> again. Reset is not enough.
>
> The code to initialize the watchdog is
>
> // initialize the watchdog timer
> WDTC = 0xffffffff; // 15000000; // One second
> = 15000000
> WDMOD = WDEN | WDRESET; // Activate watchdog
> WDFEED = 0xAA; WDFEED = 0x55;
>
> I must have misunderstood the WD functionality. What am I doing wrong?
> In the above code the watchdog should not trigger until 5 minutes
> elapsed so even if a vector should be wrong the code that follow should
> run for a while but as soon as I write to the WDMOD register I get a hang.
>
> /Ake
>
> --
> ---
> Ake Hedman (YAP - Yet Another Programmer)
> eurosource, Brattbergaven 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





Jim Parziale wrote:

> Assuming you have the correct definitions for your symbols, the only
> thing I
> can think of is setting the timeout to the largest integer like that.
> Maybe
> you could try a different large integer?
>
> These are what you should be using:
> WDEN = BIT(0) = 0x00000001
> WDRESET = BIT(1) = 0x00000002
> WDMOD = (uint8_t *)(0xE0000000)
> WDTC = (uint32_t *)(0xE0000004)
> WDFEED = (uint8_t *)(0xE0000008)

Jim,

yes my defines are the same and yes I have tested with other values for
the watchdog period. According to the manual the watchdog timer should
start when the 0xaa, 0x55 sequence is written but my problems are occurs
as soon as I write to the WDMOD register.

What situations can prevent the bootloader from working after a reset?

/Ake

>
> ----------------------
> Jim Parziale
> Email: nuncio.bitis@nunc...
> Malden, MA
> ----------------------
>
> On 12/6/05, Ake Hedman, eurosource <akhe@akhe...> wrote:
> >
> > Hi all.
> >
> > I am trying to enable the watchdog but the result is a total hang of the
> > board. Not even the bootloader is possible to reach after the crash and
> > I have to reapply power with P0.14 low to get access to the botloader
> > again. Reset is not enough.
> >
> > The code to initialize the watchdog is
> >
> > // initialize the watchdog timer
> > WDTC = 0xffffffff; // 15000000; // One second
> > = 15000000
> > WDMOD = WDEN | WDRESET; // Activate watchdog
> > WDFEED = 0xAA; WDFEED = 0x55;
> >
> > I must have misunderstood the WD functionality. What am I doing wrong?
> > In the above code the watchdog should not trigger until 5 minutes
> > elapsed so even if a vector should be wrong the code that follow should
> > run for a while but as soon as I write to the WDMOD register I get a
> hang.
> >
> > /Ake
> >
> > --
> > ---
> > Ake Hedman (YAP - Yet Another Programmer)
> > eurosource, Brattbergaven 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
> >
> >
> >. >
>


--
---
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


I have found part of this problem. The GNU compiler translates

WDFEED = 0xAA; WDFEED = 0x55;

to

710 04c4 8E22A0E3 mov r2, #-536870904
711 04c8 5530E0E3 mvn r3, #85
712 04cc 0030C2E5 strb r3, [r2, #0]
713 04d0 8E22A0E3 mov r2, #-536870904
714 04d4 5530A0E3 mov r3, #85
715 04d8 0030C2E5 strb r3, [r2, #0] i.e. just writing 0x55. This is done even if compiled with
optimization of.

Anyone know how to work around this?

Watchdog registers are currently defined as

// Watchdog
#define WDMOD (*((volatile unsigned char *) 0xE0000000))
#define WDTC (*((volatile unsigned long *) 0xE0000004))
#define WDFEED (*((volatile unsigned char *) 0xE0000008))
#define WDTV (*((volatile unsigned long *) 0xE000000C))
/Ake Ake Hedman, eurosource wrote:

>
> Jim Parziale wrote:
>
> > Assuming you have the correct definitions for your symbols, the only
> > thing I
> > can think of is setting the timeout to the largest integer like that.
> > Maybe
> > you could try a different large integer?
> >
> > These are what you should be using:
> > WDEN = BIT(0) = 0x00000001
> > WDRESET = BIT(1) = 0x00000002
> > WDMOD = (uint8_t *)(0xE0000000)
> > WDTC = (uint32_t *)(0xE0000004)
> > WDFEED = (uint8_t *)(0xE0000008)
>
> Jim,
>
> yes my defines are the same and yes I have tested with other values for
> the watchdog period. According to the manual the watchdog timer should
> start when the 0xaa, 0x55 sequence is written but my problems are occurs
> as soon as I write to the WDMOD register.
>
> What situations can prevent the bootloader from working after a reset?
>
> /Ake
>
> >
> > ----------------------
> > Jim Parziale
> > Email: nuncio.bitis@nunc...
> > Malden, MA
> > ----------------------
> >
> > On 12/6/05, Ake Hedman, eurosource <akhe@akhe...> wrote:
> > >
> > > Hi all.
> > >
> > > I am trying to enable the watchdog but the result is a total hang
> of the
> > > board. Not even the bootloader is possible to reach after the
> crash and
> > > I have to reapply power with P0.14 low to get access to the botloader
> > > again. Reset is not enough.
> > >
> > > The code to initialize the watchdog is
> > >
> > > // initialize the watchdog timer
> > > WDTC = 0xffffffff; // 15000000; // One
> second
> > > = 15000000
> > > WDMOD = WDEN | WDRESET; // Activate watchdog
> > > WDFEED = 0xAA; WDFEED = 0x55;
> > >
> > > I must have misunderstood the WD functionality. What am I doing wrong?
> > > In the above code the watchdog should not trigger until 5 minutes
> > > elapsed so even if a vector should be wrong the code that follow
> should
> > > run for a while but as soon as I write to the WDMOD register I get a
> > hang.
> > >
> > > /Ake
> > >
> > > --
> > > ---
> > > Ake Hedman (YAP - Yet Another Programmer)
> > > eurosource, Brattbergaven 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
> > >
> > >
> >
> >
> >
> >
> >
> >
> > >.
> >
> >
> >
> > --
> ---
> 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 >
>
> SPONSORED LINKS
> Microprocessor
> <http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=tsVC-J9hJ5qyXg0WPR0l6g>
> Microcontrollers
> <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=DvJVNqC_pqRTm8Xq01nxwg>
> Pic microcontrollers
> <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=TpkoX4KofDJ7c6LyBvUqVQ>
>
> 8051 microprocessor
> <http://groups.yahoo.com/gads?t=ms&k51+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=1Ipf1Fjfbd_HVIlekkDP-A >
>
> >. >
>


--
---
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


Actually it is writing 0xAA then 0x55. The second line of the
disassembly is mvn (move negative). It loads the inverted value
of 85=0x55 (0xFFFFFFAA) into r3. The next line stores the low
order byte WFEED (-536870904=0xE0000008).

Regards
-Bill Knight
R O SoftWare &
http://www.theARMPatch.com On Tue, 06 Dec 2005 21:22:21 +0100, Ake Hedman, eurosource wrote:

>I have found part of this problem. The GNU compiler translates

>WDFEED = 0xAA; WDFEED = 0x55;

>to

>710 04c4 8E22A0E3 mov r2, #-536870904
>711 04c8 5530E0E3 mvn r3, #85
>712 04cc 0030C2E5 strb r3, [r2, #0]
>713 04d0 8E22A0E3 mov r2, #-536870904
>714 04d4 5530A0E3 mov r3, #85
>715 04d8 0030C2E5 strb r3, [r2, #0]


>i.e. just writing 0x55. This is done even if compiled with
>optimization of.

>Anyone know how to work around this?

>Watchdog registers are currently defined as

>// Watchdog
>#define WDMOD (*((volatile unsigned char *) 0xE0000000))
>#define WDTC (*((volatile unsigned long *) 0xE0000004))
>#define WDFEED (*((volatile unsigned char *) 0xE0000008))
>#define WDTV (*((volatile unsigned long *) 0xE000000C))
>/Ake


>Ake Hedman, eurosource wrote:

>>
>> Jim Parziale wrote:
>>
>> > Assuming you have the correct definitions for your symbols, the only
>> > thing I
>> > can think of is setting the timeout to the largest integer like that.
>> > Maybe
>> > you could try a different large integer?
>> >
>> > These are what you should be using:
>> > WDEN = BIT(0) = 0x00000001
>> > WDRESET = BIT(1) = 0x00000002
>> > WDMOD = (uint8_t *)(0xE0000000)
>> > WDTC = (uint32_t *)(0xE0000004)
>> > WDFEED = (uint8_t *)(0xE0000008)
>>
>> Jim,
>>
>> yes my defines are the same and yes I have tested with other values for
>> the watchdog period. According to the manual the watchdog timer should
>> start when the 0xaa, 0x55 sequence is written but my problems are occurs
>> as soon as I write to the WDMOD register.
>>
>> What situations can prevent the bootloader from working after a reset?
>>
>> /Ake
>>
>> >
>> > ----------------------
>> > Jim Parziale
>> > Email: nuncio.bitis@nunc...
>> > Malden, MA
>> > ----------------------
>> >
>> > On 12/6/05, Ake Hedman, eurosource <akhe@akhe...> wrote:
>> > >
>> > > Hi all.
>> > >
>> > > I am trying to enable the watchdog but the result is a total hang
>> of the
>> > > board. Not even the bootloader is possible to reach after the
>> crash and
>> > > I have to reapply power with P0.14 low to get access to the botloader
>> > > again. Reset is not enough.
>> > >
>> > > The code to initialize the watchdog is
>> > >
>> > > // initialize the watchdog timer
>> > > WDTC = 0xffffffff; // 15000000; // One
>> second
>> > > = 15000000
>> > > WDMOD = WDEN | WDRESET; // Activate watchdog
>> > > WDFEED = 0xAA; WDFEED = 0x55;
>> > >
>> > > I must have misunderstood the WD functionality. What am I doing wrong?
>> > > In the above code the watchdog should not trigger until 5 minutes
>> > > elapsed so even if a vector should be wrong the code that follow
>> should
>> > > run for a while but as soon as I write to the WDMOD register I get a
>> > hang.
>> > >
>> > > /Ake
>> > >
>> > > --
>> > > ---
>> > > Ake Hedman (YAP - Yet Another Programmer)
>> > > eurosource, Brattbergaven 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
>> > >
>> > >
>> >
>> >
>> >
>> >
>> >
>> >
>> > >.
>> >
>> >
>> >
>> >
>>
>>
>> --
>> ---
>> 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
>>
>>
>>
>>
>>
>>
>>
>> SPONSORED LINKS
>> Microprocessor
>> <http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=tsVC-J9hJ5qyXg0WPR0l6g>
>> Microcontrollers
>> <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=DvJVNqC_pqRTm8Xq01nxwg>
>> Pic microcontrollers
>> <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=TpkoX4KofDJ7c6LyBvUqVQ>
>>
>> 8051 microprocessor
>> <http://groups.yahoo.com/gads?t=ms&k51+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=1Ipf1Fjfbd_HVIlekkDP-A>
>>
>>
>>
>>
>> >.
>>
>>
>>
>>


>--
> ---
>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
>

>
>Yahoo! Groups Links
>


Ake Hedman, eurosource wrote:

>I have found part of this problem. The GNU compiler translates
>
>WDFEED = 0xAA; WDFEED = 0x55;
>
>to
>
>710 04c4 8E22A0E3 mov r2, #-536870904
>711 04c8 5530E0E3 mvn r3, #85
>712 04cc 0030C2E5 strb r3, [r2, #0]
>713 04d0 8E22A0E3 mov r2, #-536870904
>714 04d4 5530A0E3 mov r3, #85
>715 04d8 0030C2E5 strb r3, [r2, #0] >i.e. just writing 0x55. This is done even if compiled with
>optimization of.
>
>Anyone know how to work around this? >
do you have WDFEED declared as "volatile"? This tells gcc not to
optimize out accesses to that memory, that the memory location may
change between readings (as in the case of an interrupt writing to that
location).

example:

volatile char * WDFEED; >Watchdog registers are currently defined as
>
>// Watchdog
>#define WDMOD (*((volatile unsigned char *) 0xE0000000))
>#define WDTC (*((volatile unsigned long *) 0xE0000004))
>#define WDFEED (*((volatile unsigned char *) 0xE0000008))
>#define WDTV (*((volatile unsigned long *) 0xE000000C)) >
>/Ake >Ake Hedman, eurosource wrote: >
>>Jim Parziale wrote:
>>
>>
>>
>>>Assuming you have the correct definitions for your symbols, the only
>>>thing I
>>>can think of is setting the timeout to the largest integer like that.
>>>Maybe
>>>you could try a different large integer?
>>>
>>>These are what you should be using:
>>>WDEN = BIT(0) = 0x00000001
>>>WDRESET = BIT(1) = 0x00000002
>>>WDMOD = (uint8_t *)(0xE0000000)
>>>WDTC = (uint32_t *)(0xE0000004)
>>>WDFEED = (uint8_t *)(0xE0000008)
>>>
>>>
>>Jim,
>>
>>yes my defines are the same and yes I have tested with other values for
>>the watchdog period. According to the manual the watchdog timer should
>>start when the 0xaa, 0x55 sequence is written but my problems are occurs
>>as soon as I write to the WDMOD register.
>>
>>What situations can prevent the bootloader from working after a reset?
>>
>>/Ake
>>
>>
>>
>>>----------------------
>>>Jim Parziale
>>>Email: nuncio.bitis@nunc...
>>>Malden, MA
>>>----------------------
>>>
>>>On 12/6/05, Ake Hedman, eurosource <akhe@akhe...> wrote:
>>>
>>>
>>>> Hi all.
>>>>
>>>>I am trying to enable the watchdog but the result is a total hang
>>>>
>>>>
>>of the
>>
>>
>>>>board. Not even the bootloader is possible to reach after the
>>>>
>>>>
>>crash and
>>
>>
>>>>I have to reapply power with P0.14 low to get access to the botloader
>>>>again. Reset is not enough.
>>>>
>>>>The code to initialize the watchdog is
>>>>
>>>> // initialize the watchdog timer
>>>> WDTC = 0xffffffff; // 15000000; // One
>>>>
>>>>
>>second
>>
>>
>>>>= 15000000
>>>> WDMOD = WDEN | WDRESET; // Activate watchdog
>>>> WDFEED = 0xAA; WDFEED = 0x55;
>>>>
>>>>I must have misunderstood the WD functionality. What am I doing wrong?
>>>>In the above code the watchdog should not trigger until 5 minutes
>>>>elapsed so even if a vector should be wrong the code that follow
>>>>
>>>>
>>should
>>
>>
>>>>run for a while but as soon as I write to the WDMOD register I get a
>>>>
>>>>
>>>hang.
>>>
>>>
>>>>/Ake
>>>>
>>>>--
>>>>---
>>>>Ake Hedman (YAP - Yet Another Programmer)
>>>>eurosource, Brattbergaven 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
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>>.
>>>
>>>
>>>
>>>
>>>
>>>
>>--
>>---
>>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
>>
>>
>>
>>
>>
>>
>>
>>SPONSORED LINKS
>>Microprocessor
>><http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=tsVC-J9hJ5qyXg0WPR0l6g>
>> Microcontrollers
>><http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=DvJVNqC_pqRTm8Xq01nxwg>
>> Pic microcontrollers
>><http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=TpkoX4KofDJ7c6LyBvUqVQ>
>>
>>8051 microprocessor
>><http://groups.yahoo.com/gads?t=ms&k51+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=1Ipf1Fjfbd_HVIlekkDP-A>
>>
>>
>>
>>
>>>.
>>
>>
>>
>>
>>
> >
>


--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------


Bill Knight wrote:

>Actually it is writing 0xAA then 0x55. The second line of the
>disassembly is mvn (move negative). It loads the inverted value
>of 85=0x55 (0xFFFFFFAA) into r3. The next line stores the low
>order byte WFEED (-536870904=0xE0000008). >
Ah! Didn't notice that, you are correct. Reading ARM asm still makes
my head hurt!

TomW >Regards
>-Bill Knight
>R O SoftWare &
>http://www.theARMPatch.com >On Tue, 06 Dec 2005 21:22:21 +0100, Ake Hedman, eurosource wrote: >
>>I have found part of this problem. The GNU compiler translates
>>
> >
>>WDFEED = 0xAA; WDFEED = 0x55;
>>
> >
>>to
>>
> >
>>710 04c4 8E22A0E3 mov r2, #-536870904
>>711 04c8 5530E0E3 mvn r3, #85
>>712 04cc 0030C2E5 strb r3, [r2, #0]
>>713 04d0 8E22A0E3 mov r2, #-536870904
>>714 04d4 5530A0E3 mov r3, #85
>>715 04d8 0030C2E5 strb r3, [r2, #0]
>>
> >
>
>>i.e. just writing 0x55. This is done even if compiled with
>>optimization of.
>>
> >
>>Anyone know how to work around this?
>>
> >
>>Watchdog registers are currently defined as
>>
> >
>>// Watchdog
>>#define WDMOD (*((volatile unsigned char *) 0xE0000000))
>>#define WDTC (*((volatile unsigned long *) 0xE0000004))
>>#define WDFEED (*((volatile unsigned char *) 0xE0000008))
>>#define WDTV (*((volatile unsigned long *) 0xE000000C))
>>
> >>/Ake
>>
> >
>
>>Ake Hedman, eurosource wrote:
>>
> >
>>>Jim Parziale wrote:
>>>
>>>
>>>
>>>>Assuming you have the correct definitions for your symbols, the only
>>>>thing I
>>>>can think of is setting the timeout to the largest integer like that.
>>>>Maybe
>>>>you could try a different large integer?
>>>>
>>>>These are what you should be using:
>>>>WDEN = BIT(0) = 0x00000001
>>>>WDRESET = BIT(1) = 0x00000002
>>>>WDMOD = (uint8_t *)(0xE0000000)
>>>>WDTC = (uint32_t *)(0xE0000004)
>>>>WDFEED = (uint8_t *)(0xE0000008)
>>>>
>>>>
>>>Jim,
>>>
>>>yes my defines are the same and yes I have tested with other values for
>>>the watchdog period. According to the manual the watchdog timer should
>>>start when the 0xaa, 0x55 sequence is written but my problems are occurs
>>>as soon as I write to the WDMOD register.
>>>
>>>What situations can prevent the bootloader from working after a reset?
>>>
>>>/Ake
>>>
>>>
>>>
>>>>----------------------
>>>>Jim Parziale
>>>>Email: nuncio.bitis@nunc...
>>>>Malden, MA
>>>>----------------------
>>>>
>>>>On 12/6/05, Ake Hedman, eurosource <akhe@akhe...> wrote:
>>>>
>>>>
>>>>> Hi all.
>>>>>
>>>>>I am trying to enable the watchdog but the result is a total hang
>>>>>
>>>>>
>>>of the
>>>
>>>
>>>>>board. Not even the bootloader is possible to reach after the
>>>>>
>>>>>
>>>crash and
>>>
>>>
>>>>>I have to reapply power with P0.14 low to get access to the botloader
>>>>>again. Reset is not enough.
>>>>>
>>>>>The code to initialize the watchdog is
>>>>>
>>>>> // initialize the watchdog timer
>>>>> WDTC = 0xffffffff; // 15000000; // One
>>>>>
>>>>>
>>>second
>>>
>>>
>>>>>= 15000000
>>>>> WDMOD = WDEN | WDRESET; // Activate watchdog
>>>>> WDFEED = 0xAA; WDFEED = 0x55;
>>>>>
>>>>>I must have misunderstood the WD functionality. What am I doing wrong?
>>>>>In the above code the watchdog should not trigger until 5 minutes
>>>>>elapsed so even if a vector should be wrong the code that follow
>>>>>
>>>>>
>>>should
>>>
>>>
>>>>>run for a while but as soon as I write to the WDMOD register I get a
>>>>>
>>>>>
>>>>hang.
>>>>
>>>>
>>>>>/Ake
>>>>>
>>>>>--
>>>>>---
>>>>>Ake Hedman (YAP - Yet Another Programmer)
>>>>>eurosource, Brattbergaven 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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>--
>>>---
>>>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
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>SPONSORED LINKS
>>>Microprocessor
>>><http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=tsVC-J9hJ5qyXg0WPR0l6g>
>>> Microcontrollers
>>><http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=DvJVNqC_pqRTm8Xq01nxwg>
>>> Pic microcontrollers
>>><http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=TpkoX4KofDJ7c6LyBvUqVQ>
>>>
>>>8051 microprocessor
>>><http://groups.yahoo.com/gads?t=ms&k51+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=1Ipf1Fjfbd_HVIlekkDP-A>
>>>
>>>
>>>
>>>
>>>>.
>>>
>>>
>>>
>>>
>>>
>> >
>
>>--
>>---
>>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
>>
> >>
>>
> >
>>Yahoo! Groups Links
>>
> >Yahoo! Groups Links


--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------


Are you "tickling" the watchdog? Once enabled, you must reset the timer regularly - to tell the WDT that life is good. Otherwise it will bite you by resetting (in a loop)
_____

From: lpc2000@lpc2... [mailto:lpc2000@lpc2...] On Behalf Of Jim Parziale
Sent: Tuesday, December 06, 2005 7:37 AM
To: lpc2000@lpc2...
Subject: Re: [lpc2000] Problem with watchdog
Assuming you have the correct definitions for your symbols, the only thing I
can think of is setting the timeout to the largest integer like that. Maybe
you could try a different large integer?

These are what you should be using:
WDEN = BIT(0) = 0x00000001
WDRESET = BIT(1) = 0x00000002
WDMOD = (uint8_t *)(0xE0000000)
WDTC = (uint32_t *)(0xE0000004)
WDFEED = (uint8_t *)(0xE0000008)

----------------------
Jim Parziale
Email: nuncio.bitis@nunc...
Malden, MA
----------------------

On 12/6/05, Ake Hedman, eurosource <akhe@akhe...> wrote:
>
> Hi all.
>
> I am trying to enable the watchdog but the result is a total hang of the
> board. Not even the bootloader is possible to reach after the crash and
> I have to reapply power with P0.14 low to get access to the botloader
> again. Reset is not enough.
>
> The code to initialize the watchdog is
>
> // initialize the watchdog timer
> WDTC = 0xffffffff; // 15000000; // One second
> = 15000000
> WDMOD = WDEN | WDRESET; // Activate watchdog
> WDFEED = 0xAA; WDFEED = 0x55;
>
> I must have misunderstood the WD functionality. What am I doing wrong?
> In the above code the watchdog should not trigger until 5 minutes
> elapsed so even if a vector should be wrong the code that follow should
> run for a while but as soon as I write to the WDMOD register I get a hang.
>
> /Ake
>
> --
> ---
> Ake Hedman (YAP - Yet Another Programmer)
> eurosource, Brattbergaven 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

_____

> .
_____


Ooops..! Thanks a lot. wishful thinking from my part I guess. ;-)

I'm back on square one then. hmmm... I really need to solve this.

I have done a small program that initialize the watchdog as of my
previous example and then just loop while "feeding the dog" just after
a debug output on the serial channel. But the result is the same. No
output and I have to hold p0.14 low and re power the board to be able to
bootload it.

/Ake Bill Knight wrote:

> Actually it is writing 0xAA then 0x55. The second line of the
> disassembly is mvn (move negative). It loads the inverted value
> of 85=0x55 (0xFFFFFFAA) into r3. The next line stores the low
> order byte WFEED (-536870904=0xE0000008).
>
> Regards
> -Bill Knight
> R O SoftWare &
> http://www.theARMPatch.com > On Tue, 06 Dec 2005 21:22:21 +0100, Ake Hedman, eurosource wrote:
>
> >I have found part of this problem. The GNU compiler translates
>
> >WDFEED = 0xAA; WDFEED = 0x55;
>
> >to
>
> >710 04c4 8E22A0E3 mov r2, #-536870904
> >711 04c8 5530E0E3 mvn r3, #85
> >712 04cc 0030C2E5 strb r3, [r2, #0]
> >713 04d0 8E22A0E3 mov r2, #-536870904
> >714 04d4 5530A0E3 mov r3, #85
> >715 04d8 0030C2E5 strb r3, [r2, #0] > >i.e. just writing 0x55. This is done even if compiled with
> >optimization of.
>
> >Anyone know how to work around this?
>
> >Watchdog registers are currently defined as
>
> >// Watchdog
> >#define WDMOD (*((volatile unsigned char *) 0xE0000000))
> >#define WDTC (*((volatile unsigned long *) 0xE0000004))
> >#define WDFEED (*((volatile unsigned char *) 0xE0000008))
> >#define WDTV (*((volatile unsigned long *) 0xE000000C)) >
> >/Ake > >Ake Hedman, eurosource wrote:
>
> >>
> >> Jim Parziale wrote:
> >>
> >> > Assuming you have the correct definitions for your symbols, the only
> >> > thing I
> >> > can think of is setting the timeout to the largest integer like
> that.
> >> > Maybe
> >> > you could try a different large integer?
> >> >
> >> > These are what you should be using:
> >> > WDEN = BIT(0) = 0x00000001
> >> > WDRESET = BIT(1) = 0x00000002
> >> > WDMOD = (uint8_t *)(0xE0000000)
> >> > WDTC = (uint32_t *)(0xE0000004)
> >> > WDFEED = (uint8_t *)(0xE0000008)
> >>
> >> Jim,
> >>
> >> yes my defines are the same and yes I have tested with other values for
> >> the watchdog period. According to the manual the watchdog timer should
> >> start when the 0xaa, 0x55 sequence is written but my problems are
> occurs
> >> as soon as I write to the WDMOD register.
> >>
> >> What situations can prevent the bootloader from working after a reset?
> >>
> >> /Ake
> >>
> >> >
> >> > ----------------------
> >> > Jim Parziale
> >> > Email: nuncio.bitis@nunc...
> >> > Malden, MA
> >> > ----------------------
> >> >
> >> > On 12/6/05, Ake Hedman, eurosource <akhe@akhe...> wrote:
> >> > >
> >> > > Hi all.
> >> > >
> >> > > I am trying to enable the watchdog but the result is a total hang
> >> of the
> >> > > board. Not even the bootloader is possible to reach after the
> >> crash and
> >> > > I have to reapply power with P0.14 low to get access to the
> botloader
> >> > > again. Reset is not enough.
> >> > >
> >> > > The code to initialize the watchdog is
> >> > >
> >> > > // initialize the watchdog timer
> >> > > WDTC = 0xffffffff; // 15000000; // One
> >> second
> >> > > = 15000000
> >> > > WDMOD = WDEN | WDRESET; // Activate watchdog
> >> > > WDFEED = 0xAA; WDFEED = 0x55;
> >> > >
> >> > > I must have misunderstood the WD functionality. What am I doing
> wrong?
> >> > > In the above code the watchdog should not trigger until 5 minutes
> >> > > elapsed so even if a vector should be wrong the code that follow
> >> should
> >> > > run for a while but as soon as I write to the WDMOD register I
> get a
> >> > hang.
> >> > >
> >> > > /Ake
> >> > >
> >> > > --
> >> > > ---
> >> > > Ake Hedman (YAP - Yet Another Programmer)
> >> > > eurosource, Brattbergaven 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
> >> > >
> >> > >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
>
> >> > >.
> >> >
> >> >
> >> >
>
> >> >
> >>
> >>
> >> --
> >> ---
> >> 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
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> SPONSORED LINKS
> >> Microprocessor
> >>
> <http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=tsVC-J9hJ5qyXg0WPR0l6g
> <http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=tsVC-J9hJ5qyXg0WPR0l6g>>
>
> >> Microcontrollers
> >>
> <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=DvJVNqC_pqRTm8Xq01nxwg
> <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=DvJVNqC_pqRTm8Xq01nxwg>>
>
> >> Pic microcontrollers
> >>
> <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=TpkoX4KofDJ7c6LyBvUqVQ
> <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=TpkoX4KofDJ7c6LyBvUqVQ>>
>
> >>
> >> 8051 microprocessor
> >>
> <http://groups.yahoo.com/gads?t=ms&k51+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=1Ipf1Fjfbd_HVIlekkDP-A
> <http://groups.yahoo.com/gads?t=ms&k51+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w451+microprocessor&c=4&s&.sig=1Ipf1Fjfbd_HVIlekkDP-A>>
>
> >>
> >>
> >>
> >>
>
> >> >.
> >>
> >>
> >>
>
> > > >--
> > ---
> >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 >
> >
>
> >
> >>. >
>


--
---
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


Tom Walsh wrote:

> Ake Hedman, eurosource wrote:
>
> >I have found part of this problem. The GNU compiler translates
> >
> >WDFEED = 0xAA; WDFEED = 0x55;
> >
> >to
> >
> >710 04c4 8E22A0E3 mov r2, #-536870904
> >711 04c8 5530E0E3 mvn r3, #85
> >712 04cc 0030C2E5 strb r3, [r2, #0]
> >713 04d0 8E22A0E3 mov r2, #-536870904
> >714 04d4 5530A0E3 mov r3, #85
> >715 04d8 0030C2E5 strb r3, [r2, #0]
> >
> >
> >i.e. just writing 0x55. This is done even if compiled with
> >optimization of.
> >
> >Anyone know how to work around this?
> >
> >
> >
> do you have WDFEED declared as "volatile"? This tells gcc not to
> optimize out accesses to that memory, that the memory location may
> change between readings (as in the case of an interrupt writing to that
> location).
>
> example:
>
> volatile char * WDFEED;
>
Thanks Tom,

Yes its defined as

#define WDFEED (*((volatile unsigned char *) 0xE0000008))

forgetting volatile have bite me so many times during the years.

/Ake --
---
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