Watchdog example, 2 watchdog example, Kta55/pitx software guide – Kontron KTA55-pITX User Manual

Page 17

Advertising
background image

KTD-S0043-A

Page 14

CPLD Interface


KTA55/pITX Software Guide

6.2

Watchdog Example

The following example (DOS program) show the access to the CPLD features (C compiler: BORLAND C++).
Note: These programs cannot be run on Linux and Windows

®

.

#include <stdio.h>
#include <dos.h>

#define CPLD_BASE_ADDR

0xA80

#define WDT_INDEX

0xA2

#define WDT_TIMER

0xA3

#define WDT_ENABLE

0x40

#define WDT_TRIGGER

0x80

#define WDT_1SEC

0x00

#define WDT_5SEC

0x01

#define WDT_10SEC

0x02

#define WDT_30SEC

0x03

#define WDT_1MIN

0x10

#define WDT_5MIN

0x11

#define WDT_10MIN

0x12


void ActivateWatchdog (void)
{

outp (CPLD_BASE_ADDR, WDT_INDEX);

outp

(CPLD_BASE_ADDR+1,

WDT_10SEC);

delay

(1);

// wait one millisecond

outp (CPLD_BASE_ADDR+1, WDT_ENABLE | WDT_10SEC);

}

void TriggerWatchdog (void)
{

outp (CPLD_BASE_ADDR, WDT_INDEX);

outp (CPLD_BASE_ADDR+1, WDT_ENABLE | WDT_TRIGGER | WDT_10SEC);

delay

(1);

// wait one millisecond

outp (CPLD_BASE_ADDR, WDT_TIMER);

inp

(CPLD_BASE_ADDR+1);

}

void main (void)
{
int

i;

ActivateWatchdog

();

for (i = 0; i < 5; i++)

// wait half of expiry time (= 5 seconds)

delay

(1000);

// wait 1 second

TriggerWatchdog

();

// trigger the watchdog - total expiry time now 15 seconds

}

Advertising
This manual is related to the following products: