This commit is contained in:
Meruemon
2022-04-21 11:44:14 +02:00
parent d37f6ec90e
commit 8187ea4f57
18 changed files with 123 additions and 80 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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() {

View File

@@ -1,14 +0,0 @@
package Model.InterruptHandling;
import Model.Microcontroller.PIC;
public class InterruptServiceHandler {
private PIC oPIC;
public InterruptServiceHandler(PIC oPIC) {
this.oPIC = oPIC;
}
}

View File

@@ -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() {}
}

View File

@@ -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
*

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,7 @@
package View;
import javax.swing.JPanel;
public class GUIStackButtons extends JPanel {
}

View File

@@ -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");
}
}