UC-7400-LX Plus User’s Manual
Programmer’s Guide
5-6
WDT (Watch dog Timer)
1.
Introduction
The WDT works like a watchdog to monitor system by protecting the system against
unexpected errors.
2.
How does the WDT work?
WDT has two modes: kernel mode and user mode. When the system boots up, it enters the
kernel mode by default. During normal operation, the kernel or user’s application sends
signals to the WDT to report that the system or application is working well. In kernel mode,
the kernel sends signals (acknowledgements) periodically to the WDT to keep the system
alive. If the kernel fails to acknowledge the WDT within an acknowledgement interval, the
WDT will force the system to reboot. Similarly, when users include WDT functions in their
applications, the WDT switches to user mode automatically. If the user enables the WDT and
the application does not acknowledge it, the system will reboot. You can set the
acknowledgement interval from a minimum of 50 milliseconds to a maximum of 60 seconds.
3.
The user API
The user application must include <moxadevic.h>, and link to moxalib.a. A makefile example
is shown below:
all:
arm-elf-gcc –Wl, -elf2flt –o xxxx xxxx.c -lmoxalib
int swtd_open(void)
Description
Open a file handle to control the watchdog. This is the first step to using the watchdog in
your application.
Input
None
Output
The return value is the file handle. If there is an error, it will return a negative value. You
can use errno() to retrieve the error.
int swtd_enable(int fd, unsigned long time)
Description
This function enables the watchdog function in an application. You must acknowledge
after implementing this process.
Input
int fd — the file handle, from the swtd_open() return value.
unsigned long time — The time you wish to acknowledge the watchdog periodically.
NOTE: You must acknowledge the watchdog before timeout. If you do not acknowledge,
the system will be reboot automatically. The minimum time interval is 50 milliseconds,
and the maximum time interval is 60 seconds. The time unit is in millisecond.
Output
0 if OK. An error occurs if you see a non-zero value. Use the function errno() to retrieve
the error code.