
VDX-6318 Windows Embedded Compact 7 - Getting Started Guide
Windows Embedded Compact 7 Getting Started Rev 2.00
Page 107
Sample codes to configure and use WDT0:
void main(void)
{
unsigned char c;
unsigned int lTime;
outp(0x22,0x13); // Lock register
outp(0x23,0xc5); // Unlock config. register
// Configure WDT0 to trigger in 5 seconds
lTime = 0x20L * 5000L;
outp(0x22,0x3b);
outp(0x23,(lTime>>16)&0xff);
outp(0x22,0x3a);
outp(0x23,(lTime>> 8)&0xff);
outp(0x22,0x39);
outp(0x23,(lTime>> 0)&0xff);
// Configure WDT0 to reset the system when triggered
outp(0x22,0x38);
c = inp(0x23);
c &= 0x0f;
c |= 0xd0;
// 0xd0 configure the WDT0 to reset the system
// Change to 0x10 to configure WDT0 to trigger IRQ3
// Change to 0x20 to configure WDT0 to trigger IRQ4
// Change to 0x30 to configure WDT0 to trigger IRQ5
// Change to 0x40 to configure WDT0 to trigger IRQ6
// Change to 0x50 to configure WDT0 to trigger IRQ7
// Change to 0x60 to configure WDT0 to trigger IRQ9
// Change to 0x70 to configure WDT0 to trigger IRQ10
// Change to 0x90 to configure WDT0 to trigger IRQ12
// Change to 0xa0 to configure WDT0 to trigger IRQ14
// Change to 0xb0 to configure WDT0 to trigger IRQ15
// Change to 0xc0 to configure WDT0 to trigger NMI
// Change to 0xd0 to configure WDT0 to trigger system reset
outp(0x22,0x38);
outp(0x23,c);
// Enable watchdog timer
outp(0x22,0x37);
c = inp(0x23);
c |= 0x40;
outp(0x22,0x37);
outp(0x23,c);
outp(0x22,0x13); // Lock register
outp(0x23,0x00); // Lock config. register
printf("Press any key to stop trigger timer.\n");
while(!kbhit())
{
outp(0x22,0x13); // Unlock register
outp(0x23,0xc5);
outp(0x22,0x3c);
unsigned char c = inp(0x23);
outp(0x22,0x3c);
outp(0x23,c|0x40);
outp(0x22,0x13); // Lock register
outp(0x23,0x00);
}
printf("System will reboot after 5 seconds.\n");
}