//convert it to seconds since 1970 time_val.tv_sec = mktime (&tm_val);

//set the time in the linux system clock settimeofday (&time_val, NULL);

//read the date from the realtime clock gettimeofday (&time_val, NULL);

//display the value from the clock

printf (“%s \n”, ctime ((time_t *) & time_val.tv_sec));

}

This next program is an example of how to activate and manipulate the watchdog timer.

//watchdog.c

//This sample program demonstrates how to register with

//the watchdog timer, tickle it, and finally unregister

//with it.

#include <stdio.h> #include <fcntl.h>

#include <asm/EZ328watchdog.h> void main ()

{

int watchdog_id; int watchdog_handle; int value;

long arg; value = 120;

arg = (long) &value;

//open the watchdog timer device and register

//the timeout period with it

watchdog_handle = open (“/dev/watchdog”, O_RDWR); ioctl (watchdog_handle, WATCHDOG_REGISTER, arg); watchdog_id = arg;

//hit the watchdog (reset the counter) ioctl (watchdog_handle, WATCHDOG_TICKLE,

(long)watchdog_id);

//unregister with the watchdog, disable the timer ioctl (watchdog_handle, WATCHDOG_UNREGISTER,

(long)watchdog_id); close (watchdog_handle);

}

52

www.amctechcorp.com

Page 52
Image 52
AMC 68VZ328 software manual Longwatchdogid