fixed USART interrupt handling

git-svn-id: https://mspsim.svn.sourceforge.net/svnroot/mspsim/mspsim@148 23d1a52b-0c3c-0410-b72d-8f29ab48fe35
This commit is contained in:
joxe 2008-02-27 14:33:11 +00:00
parent 1340d477bb
commit b7e2b39495
11 changed files with 28 additions and 18 deletions

View File

@ -4,7 +4,7 @@ Changes:
- fixed RSSI-ready flag to be set in CC2420
- refactored code from Sky/ESB into GenericNode
- fixed workaround for AWT/IO read line hang bug. (works but not nice in
cygwin)
cygwin). Workaround is off by default by can be configured in CLI.
- added several new commands (start, stop, step, print, printreg, etc).
0.83

View File

@ -129,7 +129,7 @@ public class Beeper extends IOUnit {
}
// Nothing for interrupts...
public void interruptServiced() {
public void interruptServiced(int vector) {
}
public static void main(String[] args) {

View File

@ -125,7 +125,7 @@ public class ADC12 extends IOUnit {
return "AD12";
}
public void interruptServiced() {
public void interruptServiced(int vector) {
}
public long ioTick(long cycles) {

View File

@ -161,7 +161,7 @@ public class BasicClockModule extends IOUnit {
return "BasicClockModule";
}
public void interruptServiced() {
public void interruptServiced(int vector) {
}
public int getModeMax() {

View File

@ -158,7 +158,7 @@ public class IOPort extends IOUnit {
return "Port " + name;
}
public void interruptServiced() {
public void interruptServiced(int vector) {
}
// for HW to set hi/low on the pins...

View File

@ -87,7 +87,7 @@ public abstract class IOUnit extends Chip {
// We should add "Interrupt serviced..." to indicate that its latest
// Interrupt was serviced...
public abstract void interruptServiced();
public abstract void interruptServiced(int vector);
// Utility function for converting 16 bits data to correct return
// value depending on address alignment and word/byte mode

View File

@ -512,9 +512,10 @@ public class MSP430Core extends Chip implements MSP430Constants {
System.out.println("### Calling serviced interrupt on: " +
servicedInterruptUnit.getName());
}
servicedInterruptUnit.interruptServiced();
servicedInterruptUnit.interruptServiced(servicedInterrupt);
}
// Find next pending interrupt
for (int i = 0, n = 16; i < n; i++) {
if (interruptSource[i] != null)
interruptMax = i;

View File

@ -113,7 +113,7 @@ public class Multiplier extends IOUnit {
return "Hardware Multiplier";
}
public void interruptServiced() {
public void interruptServiced(int vector) {
}
public int getModeMax() {

View File

@ -62,7 +62,7 @@ public class SFR extends IOUnit {
private int[] memory;
private MSP430Core cpu;
private boolean DEBUG = false;
private boolean DEBUG = true;
public SFR(MSP430Core cpu, int[] memory) {
super(memory, 0);
@ -148,7 +148,7 @@ public class SFR extends IOUnit {
else return ifg2;
}
public void interruptServiced() {
public void interruptServiced(int vector) {
}
public String getName() {

View File

@ -680,7 +680,7 @@ public class Timer extends IOUnit {
// The interrupt have been serviced...
// Some flags should be cleared (the highest priority flags)?
public void interruptServiced() {
public void interruptServiced(int vector) {
if (MSP430Core.debugInterrupts) {
System.out.println("interrupt Serviced...");
}

View File

@ -82,9 +82,6 @@ public class USART extends IOUnit {
private int receiveInterrupt = 0;
private int transmitInterrupt = 0;
private boolean rxIntEnabled = false;
private boolean txIntEnabled = false;
private int utxifg;
private int urxifg;
@ -106,6 +103,8 @@ public class USART extends IOUnit {
private int utxbuf;
private boolean txInterruptPending = false;
/**
* Creates a new <code>USART</code> instance.
*
@ -294,10 +293,19 @@ public class USART extends IOUnit {
// We should add "Interrupt serviced..." to indicate that its latest
// Interrupt was serviced...
public void interruptServiced() {
public void interruptServiced(int vector) {
// Another byte was received while the last interrupt was processed...
cpu.flagInterrupt(receiveInterrupt, this,
isIEBitsSet(urxifg) && ((getIFG() & urxifg) != 0));
if (vector == receiveInterrupt) {
cpu.flagInterrupt(receiveInterrupt, this,
isIEBitsSet(urxifg) && ((getIFG() & urxifg) != 0));
} else {
// Should we immediately make this empty again???
if (!txInterruptPending) {
cpu.flagInterrupt(transmitInterrupt, this, false);
} else {
txInterruptPending = false;
}
}
}
@ -310,7 +318,8 @@ public class USART extends IOUnit {
setBitIFG(utxifg);
utctl |= UTCTL_TXEMPTY;
cpu.flagInterrupt(transmitInterrupt, this, isIEBitsSet(utxifg));
txInterruptPending = true;
if (DEBUG) {
if (isIEBitsSet(utxifg)) {
System.out.println(getName() + " flagging on transmit interrupt");