diff --git a/bin/Control/MyControlView.class b/bin/Control/MyControlView.class index 1730438..96c37ce 100644 Binary files a/bin/Control/MyControlView.class and b/bin/Control/MyControlView.class differ diff --git a/bin/Model/Microcontroller/PIC.class b/bin/Model/Microcontroller/PIC.class index 881a5f2..9c9b3b1 100644 Binary files a/bin/Model/Microcontroller/PIC.class and b/bin/Model/Microcontroller/PIC.class differ diff --git a/bin/Model/Microcontroller/RAM.class b/bin/Model/Microcontroller/RAM.class index 754ea89..25c65bd 100644 Binary files a/bin/Model/Microcontroller/RAM.class and b/bin/Model/Microcontroller/RAM.class differ diff --git a/bin/Model/Microcontroller/RUNTIMER.class b/bin/Model/Microcontroller/RUNTIMER.class index cf5ad16..61997c0 100644 Binary files a/bin/Model/Microcontroller/RUNTIMER.class and b/bin/Model/Microcontroller/RUNTIMER.class differ diff --git a/bin/Model/MyModel.class b/bin/Model/MyModel.class index ac0acc8..d75f753 100644 Binary files a/bin/Model/MyModel.class and b/bin/Model/MyModel.class differ diff --git a/bin/View/MyView.class b/bin/View/MyView.class index e473f67..82aad5f 100644 Binary files a/bin/View/MyView.class and b/bin/View/MyView.class differ diff --git a/src/Control/MyControlView.java b/src/Control/MyControlView.java index 5cc8feb..5baf638 100644 --- a/src/Control/MyControlView.java +++ b/src/Control/MyControlView.java @@ -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 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]); } } diff --git a/src/Model/Microcontroller/PIC.java b/src/Model/Microcontroller/PIC.java index 773bdfe..427adc4 100755 --- a/src/Model/Microcontroller/PIC.java +++ b/src/Model/Microcontroller/PIC.java @@ -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(); } } \ No newline at end of file diff --git a/src/Model/Microcontroller/RAM.java b/src/Model/Microcontroller/RAM.java index 9ec8024..5f3f852 100755 --- a/src/Model/Microcontroller/RAM.java +++ b/src/Model/Microcontroller/RAM.java @@ -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 diff --git a/src/Model/Microcontroller/RUNTIMER.java b/src/Model/Microcontroller/RUNTIMER.java index 164d104..524fefd 100644 --- a/src/Model/Microcontroller/RUNTIMER.java +++ b/src/Model/Microcontroller/RUNTIMER.java @@ -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) { diff --git a/src/Model/MyModel.java b/src/Model/MyModel.java index 667a8ce..3d04820 100644 --- a/src/Model/MyModel.java +++ b/src/Model/MyModel.java @@ -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(); diff --git a/src/View/MyView.java b/src/View/MyView.java index 7cec26c..1431b61 100644 --- a/src/View/MyView.java +++ b/src/View/MyView.java @@ -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();