I need to be able to detect a WatchDog Reset for LCDX BX35

Started by ron outous June 12, 2011
I would like to use the WatchDog Reset feature of the LCDX BX35/Atmel
AT90S8535 processor. According to the available pdf documents online at
Atmel web site:

http://www.atmel.com/dyn/resources/prod_documents/DOC1041.PDF
The MCU Status Register:MCUSR should be able to indicate a WatchDog Reset.
Bits 7 thru 2 are Reserved Bits
Bit1=EXTRF:External Reset Flag
After a power-on reset, this bit is undefined (X). It can only be set by an
external reset. A watchdog reset will leave this bit unchanged. The bit is
reset by writing a logical one to the bit.
Bit0=PORF:Power On Reset Flag
This bit is only set by a power-on reset. A watchdog reset or an external
reset will leave this bit unchanged. The bit is reset by writing a logical
one to the bit.
BIT 7 6 5 4 3 2 1 0
R R R R R R R/W R/W

The pdf document states:
To summarize, the following table shows the value of these two bits after
the three modes of reset:
To make use of these bits to identify a reset condition, the user software
should clear both the PORF and EXTRF bits as early as possible in the
program. Checking the PORF and EXTRF values is done before the bits are
cleared. If the bit is cleared before an external or watchdog reset occurs,
the source of reset can be found by using the following truth table:
Table7. Reset Source Identification
EXTRF PORF Reset Source
0 0 WatchDog Reset
0 1 Power-On Reset
1 0 External Reset
1 1 Power-On Reset

I am having several problems with the above documentation:
1) No matter what the state of EXTRF and PORF before a WatchDog Reset, after
WatchDog Reset both EXTRF and PORF are reset to zero.
2) According to above instructions, to reset either EXTRF or PORF, you must
write a ONE.
To me, this just does not make any sense to write a ONE to clear the bit.

PLEASE, IF ANYONE OUT THERE HAS A SOLUTION FOR DETECTING A WATCHDOG RESET
FOR LCDX/BX35/AT90S8535, PLEASE POST IT. Thanks for any help with this.
R.Outous


I think that the Power-on-Reset cause bits are lost to the Basic-X
system boot - but that doesn't mean you can't use Watchdog.

All you need to do is start the watchdog timer with OpenWatchdog(n),
initializing it with a period that is longer than some convenient
control loop in your code, where you regularly reset it, with
Watchdog(), before it times out. If it ever times out, perhaps due to
an endless loop caused by unexpected sensor data, it will cause a
processor Reset, which restarts your code.

The .MCUSR register bits were mentioned here:
http://tech.groups.yahoo.com/group/basicx/message/20135

Tom

Tom,
I recently found reference to an "area of system memory, (0x60 to 0xCE)" in
the processor. Might it be possible to inspect some of these bytes to detect
a WatchDog Reset?

Re: CPUSleep and Watchdog?
--- In
5hRteyV3X83oYD6T02NK2x8aSa57xnauN_b1GWzTGOIG-mYbUecAmi1JKUEcw>
b..., "Tom Becker" wrote:
> How might one reliably differentiate between a startup after a "warm"
> reset [/Reset BX-24 pin 22, or a call to ResetProcessor()] and after
> a "cold" reset, i.e. the first execution after powerup.

The Register.MCUSR has two bits in it that might help. Unfortunately,
they seem to always read zero - at least on a non-P version. I don't
have a working P version to try.

It might be that the VM reads the MCUSR and stores the value in
the "system" area of memory (0x60 to 0xce) before clearing it. I
haven't attempted to determine if this is so.

Don

Thanks for your help.
R.Outous

_____

From: b... [mailto:b...] On Behalf Of
Tom Becker
Sent: Sunday, June 12, 2011 6:33 PM
To: b...
Subject: Re: [BasicX] I need to be able to detect a WatchDog Reset for LCDX
BX35

I think that the Power-on-Reset cause bits are lost to the Basic-X
system boot - but that doesn't mean you can't use Watchdog.

All you need to do is start the watchdog timer with OpenWatchdog(n),
initializing it with a period that is longer than some convenient
control loop in your code, where you regularly reset it, with
Watchdog(), before it times out. If it ever times out, perhaps due to
an endless loop caused by unexpected sensor data, it will cause a
processor Reset, which restarts your code.

The .MCUSR register bits were mentioned here:
http://tech.groups.yahoo.com/group/basicx/message/20135

Tom