UC-7400-LX Plus User’s Manual
Programmer’s Guide
5-8
4.
Special Note
When you “kill the application with -9” or “kill without option” or “Ctrl+c” the watchdog
function will be changed from user mode to kernel mode.
When your application enables the watchdog and does not acknowledge the WDT, your
application may have a logical error, or your application has made a core dump. Thus, the
watchdog function will not be changed to kernel mode. The WDT waits until the
acknowledgement timeout and force the system to reboot. This can cause a serious problem. If
errors in your application are not fixed, your system will reboot again and again.
5.
User application example
Example 1:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <moxadevice.h>
int main(int argc, char *argv[])
{
int fd;
fd = swtd_open();
if ( fd < 0 ) {
printf(“Open watchdog device fail !\n”);
exit(1);
}
swtd_enable(fd, 5000); // enable it and set it 5 seconds
while ( 1 ) {
// do user application want to do
…..
….
swtd_ack(fd);
…..
….
}
swtd_close(fd);
exit(0);
}
The makefile is shown below:
all:
arm-elf-gcc –Wl, -elf2flt –o xxxx xxxx.c –lmoxalib
Example 2:
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/time.h>
#include <moxadevice.h>
static void mydelay(unsigned long msec)
{
struct timeval
time;
time.tv_sec = msec / 1000;
time.tv_usec = (msec % 1000) * 1000;
select(1, NULL, NULL, NULL, &time);