Manual PCI-WDG-CSM
20
Foreground Watchdog Mode
In order to prevent the reset, the software program must periodically reload the Counter 1 with the initial
load value (or any other suitable load value). The maximum delay between Counter 1 reloads is
determined by the load values of the concatenated counters minus a suitable fudge factor. (Note: It is not
necessary to re-load Counter 0 because it will simply recycle. Also note that loading Counter 0 with full-
scale is customary, as exact timing is rarely a requirement of a watchdog function.)
Counter 0 must be programmed for mode 3. Counter 1 and 2 must be programmed for mode 2. The card
was designed specifically for these modes. Any other modes may cause unpredictable behavior. See
Appendix A for details on how to program the counters.
In Summary:
1.
Disable
Watchdog
Read
BASE+7
2.
Program CTR0 for Mode 3
See Appendix A
3.
Program CTR1 and 2 for Mode 2
See Appendix A
4.
Load CTR0,1,2 with reset delay
See Appendix A
5.
Enable
Watchdog
Write
BASE+7
Then, before the first timeout occurs:
1.
Enter main loop
2.
Program CTR1 (again) for Mode 2
3.
Load
CTR1
See
Appendix
A
4.
User code goes here
5.
Repeat main program loop
Background Watchdog Mode
An alternative method to refresh the counters that provides some flexibility but potentially reduces
dependability is to use an interrupt service routine (ISR). The card will generate an interrupt one Counter
0 load value before timeout occurs. If that interrupt is used by a user-defined ISR, it's possible for that
ISR to refresh the counters and, thus, avoid need for the main program loop to refresh the counters.
There is possibility of reduced dependability because this method will not detect certain types of program
lock-ups. For example, if the application program were to lock up in a loop such as "JMP $", the interrupt
service routine would never know it and would therefore continue refreshes despite the lockup. It is
possible to modify the host program to enable the ISR to detect such loops (perhaps by checking the
return stack location for the ISR each time, and making sure it changes...) However, if the code is going
to be modified, the next, hybrid, method might be more effective.
This method does, however, allow "off-the-shelf" existing programs to be used with the card without
modification. Also, this method could cause spurious resets if your program disables interrupts for an
extended duration. The IRQ that would have caused the ISR might be missed and allow the counter to
time out. If the counter counts-down, the reset signals will be generated and the counters will restart.
Combination Reset Mode
By combining the two methods ("Foreground" and "Background") it is possible to create a very elaborate
scheme for monitoring the status of the computer. This combined method eliminates the negatives
associated with either method used individually, but does require extensive modifications to existing
code, or even rewriting code entirely. In this scheme, both foreground and background routines can
prompt the watchdog.