Watchdog-Checkbox
This commit is contained in:
@ -3,18 +3,20 @@ package fabrik.simulator.pic16f84;
|
||||
public class WatchdogTimer {
|
||||
private static long watchdogTime;
|
||||
private static long lastReset = 0;
|
||||
private static boolean enabled = false;
|
||||
|
||||
private static long getTimeFromRegister() {
|
||||
return (PreScaler.isPrescalerOnTimer()) ? 18L : PreScaler.getFactor() * 18L;
|
||||
}
|
||||
|
||||
public static void testAndTrigger () {
|
||||
public static void testAndTrigger() {
|
||||
watchdogTime = getTimeFromRegister() * 1000;
|
||||
if (!PreScaler.isPrescalerOnTimer() && (Commands.getTotalExecutionTime() >= (watchdogTime + lastReset))){
|
||||
if (enabled && (Commands.getTotalExecutionTime() >= (watchdogTime + lastReset - 1))){
|
||||
DataRegister.resetPC();
|
||||
System.err.println("Watchdog Timer triggered");
|
||||
DataRegister.clearBit(3, 4);
|
||||
lastReset = Commands.getTotalExecutionTime();
|
||||
Controller_Frontend.stopRunFromBackend();
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,4 +26,12 @@ public class WatchdogTimer {
|
||||
DataRegister.setBit(3, 3);
|
||||
DataRegister.setBit(3, 4);
|
||||
}
|
||||
|
||||
public static void enable() {
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public static void disable() {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user