Timer interrupt

This commit is contained in:
Mike Schwörer 2017-05-16 10:11:35 +02:00
parent 191c10327f
commit bb37de8eb4
2 changed files with 19 additions and 2 deletions

View File

@ -66,6 +66,8 @@ namespace PIC_Simulator.PIC
public const uint INTCON_BIT_INTF = 1; // RB0/INT Interrupt Flag Bit
public const uint INTCON_BIT_RBIF = 0; // RB Port Change Interrupt Flag Bit
public const uint INTERRUPT_SERVICE_ADDRESS = 0x04;
public const string ADDWF = "000111dfffffff";
public const string ANDWF = "000101dfffffff";
@ -650,6 +652,7 @@ namespace PIC_Simulator.PIC
Stack.Push((uint) PCCounter);
PCCounter = (int) (aktueller_befehl.parameter_k - 1);
cycleCount = 2;
}
else if (aktueller_befehl.befehl == CLRWDT)
{
@ -710,7 +713,9 @@ namespace PIC_Simulator.PIC
// (INTCON < 7 >).This is a two cycle
// instruction.
//TODO
PCCounter = (int) Stack.Pop();
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE, true);
cycleCount = 2;
}
else if (aktueller_befehl.befehl == RETLW)
{
@ -981,5 +986,17 @@ namespace PIC_Simulator.PIC
PCCounter = 0;
}
public void TimerInterrupt()
{
if (!GetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE)) return;
if (!GetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_T0IE)) return;
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_T0IF, true);
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE, false);
Stack.Push((uint)PCCounter);
PCCounter = (int) INTERRUPT_SERVICE_ADDRESS;
}
}
}

View File

@ -59,7 +59,7 @@ namespace PIC_Simulator.PIC
uint Result = current + 1;
if (Result > 0xFF)
{
//TODO Interrupt PIT_TIMER
programm.TimerInterrupt();
}
Result %= 0x100;