[X] Testprogramm 11 (Watchdog, Vorteiler)

This commit is contained in:
2017-05-16 17:52:02 +02:00
parent 405b82d086
commit d4a9569693
7 changed files with 78 additions and 50 deletions

View File

@@ -1,31 +1,36 @@

namespace PIC_Simulator.PIC
{
class PICWatchDog
public class PICWatchDog
{
private PICProgramm programm;
private const double TIME_OUT = 0.018; // 18ms;
public double TimeOut = 0.018; // ms;
private const double FREQUENCY = 4000000d; // 4 MHz
public uint Prescale = 1;
private double time; // in s
public double time; // in s
public bool Aktiviert = false;
public PICWatchDog(PICProgramm p)
private Form1 form;
public PICWatchDog(PICProgramm p, Form1 frm)
{
programm = p;
time = 0;
form = frm;
}
public void Aktualisieren(uint cycles, float frequenz)
public void Aktualisieren(uint cycles)
{
if (Aktiviert)
{
time += (1.0 / frequenz) * cycles;
time += (1.0 / FREQUENCY) * cycles;
if (time > TIME_OUT * GetPreScale())
if (time > TimeOut * GetPreScale())
{
WDReset();
}
@@ -46,6 +51,7 @@ namespace PIC_Simulator.PIC
programm.Reset();
programm.SetRegisterOhneBank(PICProgramm.ADDR_STATUS, PICProgramm.STATUS_BIT_TO, false);
form.quartztimer.Stop();
}
else
{
@@ -77,10 +83,5 @@ namespace PIC_Simulator.PIC
{
time = 0;
}
public double GetPerc()
{
return time / (TIME_OUT * Prescale);
}
}
}