ZBasic System Library
186
ZX Microcontroller Family
OpenWatchDog
Type
Subroutine
Invocation
OpenWatchDog(timeout)
Parameter
Method
Type
Description
timeout
ByVal
Byte
Specifies a timeout value (see discussion).
Discussion
This subroutine prepares the watchdog timer for use. Once it is opened, the WatchDog() routine must
be called from time to time. If the period between WatchDog() calls exceeds the timeout value, the
system will be reset.
The approximate timeout value is T times 2 to the power N where T is the Timeout Base value and N is
the value of the timeout parameter limited to the range shown in the table below. Note that the timeout
value varies with processor voltage, being slightly longer at a lower operating voltage. Consult the Atmel
documentation for more specific information.
WatchDog Timeout Parameter Range
ZX Models
Timeout Base
Range
Max. Time
ZX-24, ZX-40, ZX-44
16mS
0-7
2 sec
ZX-24a, ZX-40a, ZX-44a,
ZX-24p, ZX-40p, ZX-44p,
ZX-24n, ZX-40n, ZX-44n,
ZX-24r, ZX-40r, ZX-44r,
ZX-24s, ZX-40s, ZX-44s
16mS
0-9
8 sec
ZX-24x, ZX-32a4, ZX-128a1, ZX-24xu
8mS
0-10
8 sec
ZX-328n, ZX-328l, ZX-32n, ZX-32l,
ZX-1281, ZX-1281n, ZX-1280, ZX-1280n
16mS
0-9
8 sec
ZX-24e, ZX-128e, ZX-128ne
16mS
0-7
2 sec
ZX-24ae, ZX-24ne, ZX-24pe, ZX-24nu, ZX-24pu,
ZX-24ru, ZX-24su, ZX-1281e, ZX-1281ne, ZX-328nu
16mS
0-9
8 sec
When the processor is reset, the register value Register.ResetFlags contains bit flags indicating the
source of the reset. It is important to note that the occurrence of a system fault (e.g. a stack overflow) will
also cause a WatchDog reset as will calling ResetProcessor(). See the section on Run Time Stack
Checking in the ZBasic Reference Manual for more information on stack overflow detection.
The watchdog timer can be turned off using CloseWatchDog.
Compatibility
BasicX doesnt support Register.ResetFlags or CloseWatchDog.
See Also