RB0 und PortB interrupt
This commit is contained in:
parent
bb37de8eb4
commit
83a0a42684
@ -836,6 +836,11 @@ namespace PIC_Simulator.PIC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (index == ADDR_PORT_B)
|
||||||
|
{
|
||||||
|
Interrupt_RB(Register[index], (byte)wert);
|
||||||
|
}
|
||||||
|
|
||||||
Register[index] = (byte)(wert & 0xFF);
|
Register[index] = (byte)(wert & 0xFF);
|
||||||
|
|
||||||
if (index == ADDR_PORT_A || index == ADDR_TRIS_A)
|
if (index == ADDR_PORT_A || index == ADDR_TRIS_A)
|
||||||
@ -861,6 +866,42 @@ namespace PIC_Simulator.PIC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Interrupt_RB(byte alt, byte neu)
|
||||||
|
{
|
||||||
|
// RB0/INT
|
||||||
|
|
||||||
|
if (GetBit(alt, 0) != GetBit(neu, 0))
|
||||||
|
{
|
||||||
|
if (GetRegisterOhneBank(ADDR_OPTION, OPTION_BIT_INTEDG) && GetBit(neu, 0)) // aufsteigende flanke
|
||||||
|
{
|
||||||
|
RB0Interrupt();
|
||||||
|
}
|
||||||
|
else if (!GetRegisterOhneBank(ADDR_OPTION, OPTION_BIT_INTEDG) && !GetBit(neu, 0)) // Fallende flanke
|
||||||
|
{
|
||||||
|
RB0Interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PORT RB
|
||||||
|
|
||||||
|
if (GetBit(alt, 4) != GetBit(neu, 4) && GetRegisterOhneBank(ADDR_TRIS_B, 4))
|
||||||
|
{
|
||||||
|
PortBInterrupt();
|
||||||
|
}
|
||||||
|
else if (GetBit(alt, 5) != GetBit(neu, 5) && GetRegisterOhneBank(ADDR_TRIS_B, 5))
|
||||||
|
{
|
||||||
|
PortBInterrupt();
|
||||||
|
}
|
||||||
|
else if (GetBit(alt, 6) != GetBit(neu, 6) && GetRegisterOhneBank(ADDR_TRIS_B, 6))
|
||||||
|
{
|
||||||
|
PortBInterrupt();
|
||||||
|
}
|
||||||
|
else if (GetBit(alt, 7) != GetBit(neu, 7) && GetRegisterOhneBank(ADDR_TRIS_B, 7))
|
||||||
|
{
|
||||||
|
PortBInterrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public byte GetRegisterOhneBank(uint index)
|
public byte GetRegisterOhneBank(uint index)
|
||||||
{
|
{
|
||||||
if (index == ADDR_UNIMPL_A) return 0;
|
if (index == ADDR_UNIMPL_A) return 0;
|
||||||
@ -993,6 +1034,33 @@ namespace PIC_Simulator.PIC
|
|||||||
if (!GetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_T0IE)) return;
|
if (!GetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_T0IE)) return;
|
||||||
|
|
||||||
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_T0IF, true);
|
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_T0IF, true);
|
||||||
|
|
||||||
|
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE, false);
|
||||||
|
|
||||||
|
Stack.Push((uint)PCCounter);
|
||||||
|
PCCounter = (int) INTERRUPT_SERVICE_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RB0Interrupt()
|
||||||
|
{
|
||||||
|
if (!GetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE)) return;
|
||||||
|
if (!GetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_INTE)) return;
|
||||||
|
|
||||||
|
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_INTF, true);
|
||||||
|
|
||||||
|
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE, false);
|
||||||
|
|
||||||
|
Stack.Push((uint)PCCounter);
|
||||||
|
PCCounter = (int)INTERRUPT_SERVICE_ADDRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PortBInterrupt()
|
||||||
|
{
|
||||||
|
if (!GetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE)) return;
|
||||||
|
if (!GetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_RBIE)) return;
|
||||||
|
|
||||||
|
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_RBIF, true);
|
||||||
|
|
||||||
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE, false);
|
SetRegisterOhneBank(ADDR_INTCON, INTCON_BIT_GIE, false);
|
||||||
|
|
||||||
Stack.Push((uint)PCCounter);
|
Stack.Push((uint)PCCounter);
|
||||||
|
Loading…
Reference in New Issue
Block a user