diff --git a/bin/Control/MyControlView.class b/bin/Control/MyControlView.class index 2907a22..202c009 100644 Binary files a/bin/Control/MyControlView.class and b/bin/Control/MyControlView.class differ diff --git a/bin/Model/InterruptHandling/InterruptServiceHandler.class b/bin/Model/InterruptHandling/InterruptServiceHandler.class deleted file mode 100644 index 644bdc8..0000000 Binary files a/bin/Model/InterruptHandling/InterruptServiceHandler.class and /dev/null differ diff --git a/bin/Model/InterruptHandling/InterruptServiceHandlingTable.class b/bin/Model/InterruptHandling/InterruptServiceHandlingTable.class deleted file mode 100644 index 39a61e0..0000000 Binary files a/bin/Model/InterruptHandling/InterruptServiceHandlingTable.class and /dev/null differ diff --git a/bin/Model/Microcontroller/PIC.class b/bin/Model/Microcontroller/PIC.class index 9563a32..881a5f2 100644 Binary files a/bin/Model/Microcontroller/PIC.class and b/bin/Model/Microcontroller/PIC.class differ diff --git a/bin/Model/Microcontroller/RUNTIMER.class b/bin/Model/Microcontroller/RUNTIMER.class index 89956d8..cf5ad16 100644 Binary files a/bin/Model/Microcontroller/RUNTIMER.class and b/bin/Model/Microcontroller/RUNTIMER.class differ diff --git a/bin/Model/Microcontroller/STACK.class b/bin/Model/Microcontroller/STACK.class index 95d928c..1cfbefa 100644 Binary files a/bin/Model/Microcontroller/STACK.class and b/bin/Model/Microcontroller/STACK.class differ diff --git a/bin/Model/MyModel.class b/bin/Model/MyModel.class index 0f21172..7263bc9 100644 Binary files a/bin/Model/MyModel.class and b/bin/Model/MyModel.class differ diff --git a/bin/View/GUIStackButtons.class b/bin/View/GUIStackButtons.class new file mode 100644 index 0000000..bb083b7 Binary files /dev/null and b/bin/View/GUIStackButtons.class differ diff --git a/bin/View/GUITime.class b/bin/View/GUITime.class index 6ec77d8..868bfb1 100644 Binary files a/bin/View/GUITime.class and b/bin/View/GUITime.class differ diff --git a/src/Control/MyControlView.java b/src/Control/MyControlView.java index 1e0ebe0..7c11b06 100644 --- a/src/Control/MyControlView.java +++ b/src/Control/MyControlView.java @@ -28,6 +28,7 @@ public class MyControlView { setStack(); setTestFileTable(); setMCMenu(); + showStackPrompt(); } /** @@ -178,12 +179,13 @@ public class MyControlView { public void setTestFileTable() { if (oPIC.getEeprom().getProgramLines() != null) { if (oPIC.getRam().get_LastProgramcounter() > -1) { - - int iL = oPIC.getRam().get_LastProgramcounter(); + int[] aiProgList = oPIC.getEeprom().getProgramLines(); + for (int i = 0; i < aiProgList.length; i++) { + oMyView.getGUITestFileTable().unmarkLine(aiProgList[i]); + } int iProgC = oPIC.getRam().get_Programcounter(); - oMyView.getGUITestFileTable().unmarkLine(oPIC.getEeprom().getIndex(iL)); oMyView.getGUITestFileTable().markLine(oPIC.getEeprom().getIndex(iProgC)); } else { @@ -195,6 +197,14 @@ public class MyControlView { } } } + + public void showStackPrompt() { + if (oPIC.getStack().getStackOverflow()) { + //TODO + } else if (oPIC.getStack().getStackUnderflow()) { + //TODO + } + } public void startProgramView() { diff --git a/src/Model/InterruptHandling/InterruptServiceHandler.java b/src/Model/InterruptHandling/InterruptServiceHandler.java deleted file mode 100644 index bca602c..0000000 --- a/src/Model/InterruptHandling/InterruptServiceHandler.java +++ /dev/null @@ -1,14 +0,0 @@ -package Model.InterruptHandling; - -import Model.Microcontroller.PIC; - -public class InterruptServiceHandler { - - private PIC oPIC; - - public InterruptServiceHandler(PIC oPIC) { - this.oPIC = oPIC; - } - - -} diff --git a/src/Model/InterruptHandling/InterruptServiceHandlingTable.java b/src/Model/InterruptHandling/InterruptServiceHandlingTable.java deleted file mode 100644 index d956fd0..0000000 --- a/src/Model/InterruptHandling/InterruptServiceHandlingTable.java +++ /dev/null @@ -1,19 +0,0 @@ -package Model.InterruptHandling; - -/** - * Class contains methods which calls a method to an overhanded value. - */ -public class InterruptServiceHandlingTable { - - private final int ISR_TMR0_OVERFLOW = 1; //tmr0 overflow interrupt - private final int INT_RB0 = 2; //External interrupt over int/rb0-pin - private final int RB4 = 3; //PortB change interrupts - private final int RB5 = 4; //PortB change interrupts - private final int RB6 = 5; //PortB change interrupts - private final int RB7 = 6; //PortB change interrupts - private final int EEPROM_DATA_WRITE = 7; - - public InterruptServiceHandlingTable() {} - - -} diff --git a/src/Model/Microcontroller/PIC.java b/src/Model/Microcontroller/PIC.java index 20ce398..773bdfe 100755 --- a/src/Model/Microcontroller/PIC.java +++ b/src/Model/Microcontroller/PIC.java @@ -85,6 +85,37 @@ public class PIC { return Runtimer; } + public boolean interruptAcknowledged() { + boolean bInterruptAcknowledged = false; + + if (this.getRam().get_GIE()) { + //Timer0 Interrupt + if (this.getRam().get_T0IE() && this.getRam().get_T0IF()) { + bInterruptAcknowledged = true; + } + //External RB0-pin INT Interrupt + else if (this.getRam().get_INTE() && this.getRam().get_INTF()) { + bInterruptAcknowledged = true; + } + //Port RB Interrupt + else if (this.getRam().get_RBIE() && this.getRam().get_RBIF()) { + bInterruptAcknowledged = true; + } + //EE Write complete interrupt enable + else if (this.getRam().get_EEIE() && this.getRam().get_EEIF()) { + bInterruptAcknowledged = true; + } + } + + return bInterruptAcknowledged; + } + + public void InterruptServiceRoutine() { + this.getRam().set_GIE(false); + Stack.pushReturnAdressOnStack(this.getRam().get_Programcounter()); + this.getRam().set_Programcounter(0x0004); + } + /** * Datasheet Page 57 * diff --git a/src/Model/Microcontroller/RUNTIMER.java b/src/Model/Microcontroller/RUNTIMER.java index cca638c..164d104 100644 --- a/src/Model/Microcontroller/RUNTIMER.java +++ b/src/Model/Microcontroller/RUNTIMER.java @@ -3,7 +3,7 @@ package Model.Microcontroller; public class RUNTIMER { private double dRuntime; private double dMaxWatchdog; - private double dRTIncrVal; + private double dRTIncrVal = 0.001 * (4 / 0.032); private boolean WDTE = false; diff --git a/src/Model/Microcontroller/STACK.java b/src/Model/Microcontroller/STACK.java index a794644..e8ab909 100755 --- a/src/Model/Microcontroller/STACK.java +++ b/src/Model/Microcontroller/STACK.java @@ -15,6 +15,9 @@ public class STACK private int stackpointer; private int[] stack; + private boolean bStackOverflow = false; + private boolean bStackUnderflow = false; + /** * Constructor of STACK. */ @@ -29,18 +32,15 @@ public class STACK * Pushs returnAddress on stack. If stack is full, throws StackOverflowError. * @param return_Adress */ - public void pushReturnAdressOnStack(int return_Adress) - { - if (stackpointer < 8) - { + public void pushReturnAdressOnStack(int return_Adress) { + if (stackpointer < 8) { stack[stackpointer] = return_Adress; stackpointer++; } - if (stackpointer == 8) - { - //throw new StackOverflowError(); + if (stackpointer == 8) { stackpointer = 0; + bStackOverflow = true; } } @@ -55,12 +55,15 @@ public class STACK throw new EmptyStackException(); } else { stackpointer--; + if (stackpointer == -1) { + stackpointer = 7; + bStackUnderflow = true; + } adressToReturn = stack[stackpointer]; stack[stackpointer] = -1; } - if (stackpointer == -1) - stackpointer = 7; + return adressToReturn; } @@ -100,4 +103,20 @@ public class STACK return noObjects; } + + public boolean getStackOverflow() { + return bStackOverflow; + } + + public void resetStackOverflow() { + bStackOverflow = false; + } + + public boolean getStackUnderflow() { + return bStackUnderflow; + } + + public void resetStackUnderflow() { + bStackUnderflow = false; + } } \ No newline at end of file diff --git a/src/Model/MyModel.java b/src/Model/MyModel.java index 4d1e13a..be1f142 100644 --- a/src/Model/MyModel.java +++ b/src/Model/MyModel.java @@ -51,46 +51,65 @@ public class MyModel extends Thread { bStopProgram = true; }break; case (1): { - //start program + //Start program while (iProgState == 1) { //Check if pause/stop was pressed if (!qReceivedCommands.isEmpty()) { iProgState = qReceivedCommands.poll(); } - //Check if breakpoint is set - if (abBreakpoints != null) { - if (!abBreakpoints[oPIC.getRam().get_Programcounter()] && !interruptAcknowledged()) { - if(iVisualInterval > 0) { - try { - Thread.sleep(iVisualInterval * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); + //Check if interrupt was acknowledged + if (oPIC.interruptAcknowledged()) { + + } else { + //Check if breakpoints initialized + if (abBreakpoints != null) { + //Check if stack overflowed or underflowed + if (oPIC.getStack().getStackOverflow() || oPIC.getStack().getStackUnderflow()) { + qDataToView.add(oPIC); + //If stack did not over or underflow + } else { + //Check if breakpoint at [pc] is set + if (!abBreakpoints[oPIC.getRam().get_Programcounter()]) { + //Check if slow interval is active + if(iVisualInterval > 0) { + try { + Thread.sleep(iVisualInterval * 1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + //Execute step + step(); + //Update view + qDataToView.add(oPIC); + } else { + //Pause program if breakpoint at [pc] is set + iProgState = 2; } - } - step(); - qDataToView.add(oPIC); - } else { - //Pause program - iProgState = 2; - } - } + } + } + } } }break; + //Program paused case (2): { }break; + //Reset program case (3): { oPIC.resetPIC(); - qDataToView.add(oPIC); //TODO + qDataToView.add(oPIC); }break; + //Step program case (4): { + //Check if breakpoints are initialized if (abBreakpoints != null) { //Check if breakpoint is set int iProgC = oPIC.getRam().get_Programcounter(); iProgC &= abBreakpoints.length; if (!abBreakpoints[iProgC]) { step(); - qDataToView.add(oPIC); //TODO + qDataToView.add(oPIC); } } else { System.out.println("Please load file!"); @@ -125,14 +144,4 @@ public class MyModel extends Thread { iVisualInterval = oMyModelData.getVisualInterval(); qDataToView.add(oPIC); } - - private boolean interruptAcknowledged() { - boolean bInterruptAcknowledged = false; - - if (oPIC.getRam().get_GIE()) { - - } - - return bInterruptAcknowledged; - } } diff --git a/src/View/GUIStackButtons.java b/src/View/GUIStackButtons.java new file mode 100644 index 0000000..bbda50f --- /dev/null +++ b/src/View/GUIStackButtons.java @@ -0,0 +1,7 @@ +package View; + +import javax.swing.JPanel; + +public class GUIStackButtons extends JPanel { + +} \ No newline at end of file diff --git a/src/View/GUITime.java b/src/View/GUITime.java index 630237d..26ff964 100644 --- a/src/View/GUITime.java +++ b/src/View/GUITime.java @@ -35,7 +35,7 @@ public class GUITime extends JPanel { JCheckBox oEnableWDT = new JCheckBox("WDT"); double dRuntime = 0; - JLabel oLabelRuntime = new JLabel("Runtime: " + dRuntime); + JLabel oLabelRuntime = new JLabel("Runtime: " + dRuntime + "ms"); JLabel oLabelQuarz = new JLabel("Quarzfrequency"); String[] asIntervals = {"32 kHz", "100 kHz", "500 kHz", "1 MHz", "2 MHz", "4 MHz", "8 MHz", "12 MHz", "16 MHz", "20 MHz"}; @@ -77,11 +77,11 @@ public class GUITime extends JPanel { iLanguage = iLangNr; switch (iLangNr) { case 0: { - oLabelRuntime.setText("Laufzeit: " + dRuntime); + oLabelRuntime.setText("Laufzeit: " + dRuntime + "ms"); oLabelQuarz.setText("Quarzfrequenz"); }break; case 1: { - oLabelRuntime.setText("Runtime: " + dRuntime); + oLabelRuntime.setText("Runtime: " + dRuntime + "ms"); oLabelQuarz.setText("Quarzfrequency"); }break; } @@ -98,9 +98,9 @@ public class GUITime extends JPanel { public void setRuntime(double dRuntime) { this.dRuntime = dRuntime; if (iLanguage == 0) { - oLabelRuntime.setText("Laufzeit: " + dRuntime); + oLabelRuntime.setText("Laufzeit: " + dRuntime + "ms"); } else { - oLabelRuntime.setText("Runtime: " + dRuntime); + oLabelRuntime.setText("Runtime: " + dRuntime + "ms"); } }