watchdog (#33)
Co-authored-by: Darkress <30271678+DarkressX@users.noreply.github.com> Reviewed-on: darkress/pic16f84-sim#33
This commit was merged in pull request #33.
This commit is contained in:
32
de/darkress/pic16f84sim/microcontroller/Watchdog.java
Normal file
32
de/darkress/pic16f84sim/microcontroller/Watchdog.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package de.darkress.pic16f84sim.microcontroller;
|
||||
|
||||
public class Watchdog
|
||||
{
|
||||
private static int watchdogTimer = 18000;
|
||||
public static int getWatchdogTimer()
|
||||
{
|
||||
return watchdogTimer;
|
||||
}
|
||||
|
||||
public static void decreaseWatchdogTimer()
|
||||
{
|
||||
watchdogTimer--;
|
||||
checkWatchdog();
|
||||
}
|
||||
|
||||
private static void checkWatchdog()
|
||||
{
|
||||
if(watchdogTimer == 0)
|
||||
{
|
||||
System.out.println("Watchdog Time-Out");
|
||||
Memory.setRegister(0x03, Memory.getRegister(0x03) & 0xEF); //Clear !TO in StatusReg
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetProgram()
|
||||
{
|
||||
Memory.setRegister(0x03, Memory.getRegister(0x03) | 0x10);
|
||||
watchdogTimer = 18000;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user