Implemented Interrupt Prompts and Interrupt Logic?

This commit is contained in:
Meruemon
2022-04-22 14:35:34 +02:00
parent 0d5a447d36
commit 265214829a
12 changed files with 77 additions and 106 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -14,6 +14,16 @@ import View.MyView;
*/
public class MyControlView {
String[][]asPromptTitle = {
{"Timer 0 Interrupt Festgestellt", "EE Interrupt Festgestellt", "PORT B Change Interrupt Festgestellt", "RB0 Interrupt Festgestellt"},
{"Timer 0 Interrupt Acknowledged", "EE Interrupt Acknowledged", "PORT B Change Interrupt Acknowledged", "RB0 Interrupt Acknowledged"}
};
String[][]asPromptDialogs = {
{"Information Timer 0 Interrupt\nISR wird ausgeführt", "Information EE Interrupt\nISR wird ausgeführt", "Information PORT B Change Interrupt\nISR wird ausgeführt", "Information RB0 Interrupt\nISR wird ausgeführt"},
{"Information Timer 0 Interrupt\nISR will be executed", "Information EE Interrupt\nISR will be executed", "Information PORT B Change Interrupt\nISR will be executed", "Information RB0 Interrupt\nISR will be executed"}
};
MyView oMyView;
PIC oPIC;
ConcurrentLinkedQueue<Integer> qCommandsToModel;
@@ -34,8 +44,12 @@ public class MyControlView {
setStack();
setTestFileTable();
setMCMenu();
showStackPrompt();
showTimer0InterruptPrompt();
showEEInterruptPrompt();
showPORTBInterruptPrompt();
showRB0InterruptPrompt();
}
/**
@@ -208,7 +222,28 @@ public class MyControlView {
public void showTimer0InterruptPrompt() {
if (oPIC.getRam().get_GIE() && oPIC.getRam().get_T0IE() && oPIC.getRam().get_T0IF()) {
Object[] options = {"Ok"};
int n = JOptionPane.showOptionDialog(new JFrame(),"Information Timer 0 Interrupt\nISR will be executed", "Timer 0 Interrupt Acknowledged", JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]);
JOptionPane.showOptionDialog(new JFrame(), asPromptDialogs[0][oMyView.getLanguage()], asPromptTitle[0][oMyView.getLanguage()], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]);
}
}
public void showEEInterruptPrompt() { //TODO
if (oPIC.getRam().get_GIE() && oPIC.getRam().get_EEIE() && oPIC.getRam().get_EEIF()) {
Object[] options = {"Ok"};
JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[1][oMyView.getLanguage()], asPromptTitle[1][oMyView.getLanguage()], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]);
}
}
public void showPORTBInterruptPrompt() {
if (oPIC.getRam().get_GIE() && oPIC.getRam().get_RBIE() && oPIC.getRam().get_RBIF()) {
Object[] options = {"Ok"};
JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[2][oMyView.getLanguage()], asPromptTitle[2][oMyView.getLanguage()], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]);
}
}
public void showRB0InterruptPrompt() {
if (oPIC.getRam().get_GIE() && oPIC.getRam().get_INTE() && oPIC.getRam().get_INTF()) {
Object[] options = {"Ok"};
JOptionPane.showOptionDialog(new JFrame(),asPromptDialogs[3][oMyView.getLanguage()], asPromptTitle[3][oMyView.getLanguage()], JOptionPane.YES_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[1]);
}
}

View File

@@ -552,9 +552,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -574,15 +571,14 @@ public class PIC {
Ram.set_PS2(false);
//Programcounter will be incremented by 1.
Runtimer.resetWDT();
//Increment programcounter and TMR0 if assigned to TMR0.
Ram.inkrement_Programcounter(1, 0); //Kind of call
if (Ram.get_T0CS() == false) {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -629,9 +625,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -682,9 +675,6 @@ public class PIC {
NOP();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -732,9 +722,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -757,9 +744,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -808,9 +792,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -867,9 +848,6 @@ public class PIC {
NOP();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -903,9 +881,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -947,9 +922,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -970,9 +942,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1011,9 +980,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1032,9 +998,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b11111111);
Runtimer.incrementRuntime();
}
@@ -1051,9 +1014,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b11111111);
Runtimer.incrementRuntime();
}
@@ -1081,9 +1041,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1095,13 +1052,11 @@ public class PIC {
//Increment programcounter and TMR0 if assigned to TMR0.
Ram.inkrement_Programcounter(1, 0); //Kind of call
if (Ram.get_T0CS() == false) {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1129,9 +1084,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1154,9 +1106,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1213,9 +1162,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1271,9 +1217,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1297,9 +1240,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1356,9 +1296,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1389,7 +1326,7 @@ public class PIC {
int carry = (result & 0b100000000) >> 8;
//The lower four bits are bitwise and with 1111b (15d).
int dcResult = (regFileAddrValue & 15) + (wRegValue & 15) + 1;
int dcResult = (regFileAddrValue & 0x0F) + (wRegValue & 0x0F) + 1; //TODO LST File 3 DC Carry is not set.
//If the result is greater than 15, DC-Flag is set true.
if (dcResult > 15) {
@@ -1433,9 +1370,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1473,9 +1407,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1501,9 +1432,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1535,9 +1463,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
@@ -1581,9 +1506,6 @@ public class PIC {
Ram.increment_TMR0();
}
//Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM.
Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111);
Runtimer.incrementRuntime();
}
}

View File

@@ -618,6 +618,7 @@ public class RAM {
lastProgramcounter = get_Programcounter();
iProgramcounter += value;
iProgramcounter &= 0x3FF;
set_PCL(iProgramcounter & 0xFF);
}
/**
@@ -628,6 +629,7 @@ public class RAM {
lastProgramcounter = get_Programcounter();
iProgramcounter -= value;
iProgramcounter &= 0x3FF;
set_PCL(iProgramcounter & 0xFF);
}
/**
@@ -638,6 +640,7 @@ public class RAM {
public synchronized void set_Programcounter(int value) {
lastProgramcounter = iProgramcounter;
iProgramcounter = value;
set_PCL(iProgramcounter & 0xFF);
}
//Bank0 PORTA

View File

@@ -3,6 +3,8 @@ package Model.Microcontroller;
public class RUNTIMER {
private double dRuntime;
private double dMaxWatchdog;
private double dOldMaxWatchdog;
private double dWatchdogTimer;
private double dRTIncrVal = 0.001 * (4 / 0.032);
private boolean WDTE = false;
@@ -10,21 +12,29 @@ public class RUNTIMER {
private RAM oRam;
public RUNTIMER(RAM oRam) {
dWatchdogTimer = dMaxWatchdog = dOldMaxWatchdog = 18000;
this.oRam = oRam;
}
public void setMaxWatchdog(double dMaxVal) {
dWatchdogTimer = dMaxVal - (dOldMaxWatchdog - dWatchdogTimer);
dOldMaxWatchdog = dMaxWatchdog;
dMaxWatchdog = dMaxVal;
}
private void checkWatchdog() {
public void resetWDT() {
dWatchdogTimer = dMaxWatchdog;
}
private void updateWatchdog() {
if (WDTE) {
if (oRam.get_PSA()) {
setMaxWatchdog(18000 * oRam.get_WDT_PrescalerRate());
} else {
setMaxWatchdog(18000);//18 ms
}
if ((dMaxWatchdog - dRuntime) <= 0) {
dWatchdogTimer -= dRuntime;
if (dWatchdogTimer <= 0) {
System.out.println("WDT Interrupt");
}
}
@@ -40,7 +50,7 @@ public class RUNTIMER {
public void incrementRuntime() {
dRuntime += dRTIncrVal;
checkWatchdog();
updateWatchdog();
}
public void setQuarzSpeed(int iInterval) {

View File

@@ -42,16 +42,18 @@ public class MyModel extends Thread {
/* -1 == ERROR, 0 == END, 1 == START, 2 == PAUSE, 3 == RESET 4 == STEP*/
iProgState = qReceivedCommands.poll();
switch (iProgState) {
case (-1): {
//Stop program because of error
case (-1): {
System.out.println("Fehler");
bStopProgram = true;
}break;
case (0): {
//Stop Program
case (0): {
System.out.println("Programm wurde beendet.");
bStopProgram = true;
}break;
case (1): {
//Start program
//Start program
case (1): {
while (iProgState == 1) {
//Check if pause/stop was pressed
if (!qReceivedCommands.isEmpty()) {
@@ -59,7 +61,7 @@ public class MyModel extends Thread {
}
//Check if interrupt was acknowledged
if (oPIC.interruptAcknowledged()) {
//TODO
} else {
//Check if breakpoints initialized
if (abBreakpoints != null) {
@@ -120,33 +122,27 @@ public class MyModel extends Thread {
System.out.println("Please load file!");
}
}break;
//Reset Stack Overflow Bit
case (5): {
oPIC.getStack().resetStackOverflow();
}break;
//Reset Stack Underflow Bit
case (6): {
oPIC.getStack().resetStackUnderflow();
}break;
}
}
}
}
}
private void step() {
//Check if step valid
if (oPIC.getRam().get_Programcounter() < (oPIC.getEeprom().getLengthEEPROM())) {
//Makes one step through the eeprom.
Bitmask oBitmask = new Bitmask();
oBitmask.bitMaskDecoderAndExecuteCommand(oPIC.getEeprom().getElement(oPIC.getRam().get_Programcounter()), oPIC);
qDataToView.add(oPIC);
} else {
System.out.println("Step invalid, end of file reached!");
}
Bitmask oBitmask = new Bitmask();
//Makes one step through the eeprom.
oBitmask.bitMaskDecoderAndExecuteCommand(oPIC.getEeprom().getElement(oPIC.getRam().get_Programcounter()), oPIC);
//Update view
qDataToView.add(oPIC);
}
private void setModel(MyModelData data) {
oMyModelData = data;
oPIC = oMyModelData.getPIC();

View File

@@ -21,6 +21,8 @@ public class MyView implements IMyView {
private JPanel oGUIMainPanel;
private int iLang;
public MyView() {
oGUIMenuBar = new GUIMenuBar(this);
oGUIMCMenu = new GUIMCMenu();
@@ -50,6 +52,7 @@ public class MyView implements IMyView {
}
public void setLanguage(int iLangNr) {
iLang = iLangNr;
oGUIMenuBar.changeLangMenuBar(iLangNr);
oGUIMCMenu.setLanguage(iLangNr);
oGUIRegister.setLanguage(iLangNr);
@@ -57,7 +60,9 @@ public class MyView implements IMyView {
oGUITime.setLanguage(iLangNr);
}
public int getLanguage() {
return iLang;
}
public void test() {
this.getGUITime().getQuarzComboBox();