You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(12) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(25) |
Feb
(54) |
Mar
(63) |
Apr
(52) |
May
(17) |
Jun
(3) |
Jul
(3) |
Aug
(5) |
Sep
(49) |
Oct
(50) |
Nov
(34) |
Dec
(14) |
2009 |
Jan
(9) |
Feb
(15) |
Mar
(38) |
Apr
(12) |
May
(35) |
Jun
(20) |
Jul
(2) |
Aug
(7) |
Sep
(36) |
Oct
(24) |
Nov
(2) |
Dec
(2) |
2010 |
Jan
(14) |
Feb
(1) |
Mar
(36) |
Apr
(2) |
May
(4) |
Jun
(6) |
Jul
(35) |
Aug
(11) |
Sep
(8) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(11) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(12) |
Jun
(8) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
(2) |
Dec
(4) |
2012 |
Jan
(2) |
Feb
(1) |
Mar
(14) |
Apr
(5) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jo...@us...> - 2010-03-29 19:33:21
|
Revision: 687 http://mspsim.svn.sourceforge.net/mspsim/?rev=687&view=rev Author: joxe Date: 2010-03-29 19:33:15 +0000 (Mon, 29 Mar 2010) Log Message: ----------- address decode on all packets Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-29 19:12:20 UTC (rev 686) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-29 19:33:15 UTC (rev 687) @@ -571,7 +571,7 @@ if (rxread == 2) { if (TYPE_DATA_FRAME == (memory[RAM_RXFIFO + rxPacketStart] & FRAME_TYPE)) { - decodeAddress = addressDecode & (memory[RAM_RXFIFO + rxPacketStart] & ACK_REQUEST) > 0; + decodeAddress = addressDecode; ackRequest = (memory[RAM_RXFIFO + rxPacketStart] & ACK_REQUEST) > 0; destinationAddressMode = (memory[RAM_RXFIFO + ((rxPacketStart + 1) & 127)] >> 2) & 3; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-29 19:12:26
|
Revision: 686 http://mspsim.svn.sourceforge.net/mspsim/?rev=686&view=rev Author: joxe Date: 2010-03-29 19:12:20 +0000 (Mon, 29 Mar 2010) Log Message: ----------- made autoack not sending on any packet Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-29 17:58:55 UTC (rev 685) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-29 19:12:20 UTC (rev 686) @@ -266,6 +266,7 @@ private boolean autoAck = false; private boolean shouldAck = false; private boolean addressDecode = false; + private boolean ackRequest = false; private boolean autoCRC = false; private int dsn = 0; @@ -381,7 +382,7 @@ private int[] ackBuf = {0x05, 0x02, 0x00, 0x00, 0x00, 0x00}; private CCITT_CRC rxCrc = new CCITT_CRC(); private CCITT_CRC txCrc = new CCITT_CRC(); -private int rxPacketStart; + private int rxPacketStart; public void setStateListener(StateListener listener) { stateListener = listener; @@ -558,6 +559,8 @@ rxCrc.setCRC(0); rxlen = data & 0xff; rxPacketStart = rxfifoWritePos; + System.out.println("Starting to get packet at: " + rxfifoWritePos + " len = " + rxlen); + decodeAddress = false; if (DEBUG) log("RX: Start frame length " + rxlen); // FIFO pin goes high after length byte is written to RXFIFO @@ -569,7 +572,11 @@ if (rxread == 2) { if (TYPE_DATA_FRAME == (memory[RAM_RXFIFO + rxPacketStart] & FRAME_TYPE)) { decodeAddress = addressDecode & (memory[RAM_RXFIFO + rxPacketStart] & ACK_REQUEST) > 0; + ackRequest = (memory[RAM_RXFIFO + rxPacketStart] & ACK_REQUEST) > 0; destinationAddressMode = (memory[RAM_RXFIFO + ((rxPacketStart + 1) & 127)] >> 2) & 3; + } else { + decodeAddress = false; + ackRequest = false; } } else if (rxread == 3) { // save data sequence number @@ -608,6 +615,7 @@ /* reset state */ rxfifoLen = rxfifoLen - rxread; rxfifoWritePos = (rxPacketStart - 1 + 128) & 127; + System.out.println("Packet rejected by autoaddress Reverting to: " + rxfifoWritePos); setSFD(false); setFIFO(rxfifoLen > 0); setState(RadioState.RX_SFD_SEARCH); @@ -647,7 +655,8 @@ /* if either manual ack request (shouldAck) or autoack + ACK_REQ on package do ack! */ // System.out.println("Autoack " + autoAck + " checkAutoack " + checkAutoack() + " shouldAck " + shouldAck); - if ((autoAck && checkAutoack()) || shouldAck) { + if ((autoAck && ackRequest) || shouldAck) { + System.out.println("Doing Autoack on lastPacket at " + lastPacketStart + " len: " + rxlen); ackBuf[ACK_SEQPOS] = memory[RAM_RXFIFO + lastPacketStart + 2]; /* find the seq no!!! */ setState(RadioState.TX_ACK_CALIBRATE); } else { @@ -680,15 +689,7 @@ break; } } - - /* any packet that has autoack request will be acked! */ - private boolean checkAutoack() { - /* ack request or not ? */ - boolean ackReq = (memory[RAM_RXFIFO + lastPacketStart] & ACK_REQUEST) != 0; - if (!ackReq) return false; - return true; - } - + public void dataReceived(USART source, int data) { int oldStatus = status; if (DEBUG) { @@ -785,11 +786,13 @@ /* initiate read of another packet - update some variables to keep track of packet reading... */ if (rxfifoReadLeft == 0) { rxfifoReadLeft = (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF); - System.out.println("Initiating read of another packet - len: " + rxfifoReadLeft); + System.out.println("Initiating read of another packet - len: " + rxfifoReadLeft + + " fifoLen: " + rxfifoLen); } else if (--rxfifoReadLeft == 0) { /* check if we have another complete packet in buffer... */ if (rxfifoLen > 1 && rxfifoLen >= (memory[RAM_RXFIFO + (rxfifoReadPos + 1) & 127] & 0xFF) + 1) { - System.out.println("Another packet in buffer!!!"); + System.out.println("Another packet in buffer - Setting FIFOP to true! plen: " + + (memory[RAM_RXFIFO + (rxfifoReadPos + 1) & 127] & 0xFF) + " fifoLen: " + rxfifoLen); if (!overflow) setFIFOP(true); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-29 17:59:02
|
Revision: 685 http://mspsim.svn.sourceforge.net/mspsim/?rev=685&view=rev Author: joxe Date: 2010-03-29 17:58:55 +0000 (Mon, 29 Mar 2010) Log Message: ----------- fixed some bugs with CC2420 and FIFOP handlign Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/util/SimpleProfiler.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-29 13:43:00 UTC (rev 684) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-29 17:58:55 UTC (rev 685) @@ -430,6 +430,7 @@ case POWER_DOWN: rxfifoReadPos = 0; + rxfifoReadLeft = 0; rxfifoWritePos = 0; status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); reset(); @@ -632,11 +633,13 @@ (crc == rxCrc.getCRCBitrev() ? 0x80 : 0); // FIFOP should not be set if CRC is not ok??? - depends on autoCRC! - /* set FIFOP only if this is the first received packet + /* set FIFOP only if this is the first received packet - e.g. if rxfifoLen is at most rxlen + 1 * TODO: check what happens when rxfifoLen < rxlen - e.g we have been reading before FIFOP * fix support for FIFOP threshold */ - if (rxfifoLen <= rxlen) { + if (rxfifoLen <= rxlen + 1) { setFIFOP(true); + } else { + System.out.println("Did not set FIFOP rxfifoLen: " + rxfifoLen + " rxlen: " + rxlen); } setSFD(false); if (DEBUG) log("RX: Complete: packetStart: " + @@ -768,12 +771,25 @@ source.byteReceived( (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) ); if (rxfifoLen > 0) { - /* initiate read of another packet */ + /* first check and clear FIFOP - since we now have read a byte! */ + // TODO: + // -MT FIFOP is lowered when there are less than IOCFG0:FIFOP_THR bytes in the RXFIFO + // If FIFO_THR is greater than the frame length, FIFOP goes low when the first byte is read out. + // As long as we are in "OVERFLOW" the fifoP is not cleared. + if (fifoP && !overflow) { + if (DEBUG) log("*** FIFOP cleared at: " + rxfifoReadPos + + " lastPacketStartPos: " + lastPacketStart); + setFIFOP(false); + } + + /* initiate read of another packet - update some variables to keep track of packet reading... */ if (rxfifoReadLeft == 0) { rxfifoReadLeft = (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF); + System.out.println("Initiating read of another packet - len: " + rxfifoReadLeft); } else if (--rxfifoReadLeft == 0) { /* check if we have another complete packet in buffer... */ if (rxfifoLen > 1 && rxfifoLen >= (memory[RAM_RXFIFO + (rxfifoReadPos + 1) & 127] & 0xFF) + 1) { + System.out.println("Another packet in buffer!!!"); if (!overflow) setFIFOP(true); } } @@ -786,15 +802,6 @@ setFIFO(false); } - // TODO: - // -MT FIFOP is lowered when there are less than IOCFG0:FIFOP_THR bytes in the RXFIFO - // If FIFO_THR is greater than the frame length, FIFOP goes low when the first byte is read out. - // As long as we are in "OVERFLOW" the fifoP is not cleared. - if (fifoP && !overflow) { - if (DEBUG) log("*** FIFOP cleared at: " + rxfifoReadPos + - " lastPacketStartPos: " + lastPacketStart); - setFIFOP(false); - } return; case WRITE_TXFIFO: if(txfifoFlush) { @@ -1070,6 +1077,7 @@ log("Flushing RX len = " + rxfifoLen); } rxfifoReadPos = 0; + rxfifoReadLeft = 0; rxfifoWritePos = 0; rxfifoLen = 0; setSFD(false); Modified: mspsim/se/sics/mspsim/util/SimpleProfiler.java =================================================================== --- mspsim/se/sics/mspsim/util/SimpleProfiler.java 2010-03-29 13:43:00 UTC (rev 684) +++ mspsim/se/sics/mspsim/util/SimpleProfiler.java 2010-03-29 17:58:55 UTC (rev 685) @@ -470,7 +470,7 @@ tagEntry.calls++; tagEntry.cycles += cpu.cycles - tagEntry.lastCycles; tagEntry.lastCycles = 0; - } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-29 13:43:09
|
Revision: 684 http://mspsim.svn.sourceforge.net/mspsim/?rev=684&view=rev Author: joxe Date: 2010-03-29 13:43:00 +0000 (Mon, 29 Mar 2010) Log Message: ----------- fixed so that FIFOP goes high when packet is readout (if another packet is available) Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-26 14:26:37 UTC (rev 683) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-29 13:43:00 UTC (rev 684) @@ -246,6 +246,7 @@ private boolean txfifoFlush; // TXFIFO is automatically flushed on next write private int rxfifoWritePos; private int rxfifoReadPos; + private int rxfifoReadLeft; // number of bytes left to read from current packet private int rxfifoLen; private int rxlen; private int rxread; @@ -607,8 +608,7 @@ rxfifoLen = rxfifoLen - rxread; rxfifoWritePos = (rxPacketStart - 1 + 128) & 127; setSFD(false); - setFIFOP(false); - setFIFO(false); + setFIFO(rxfifoLen > 0); setState(RadioState.RX_SFD_SEARCH); } } @@ -632,9 +632,13 @@ (crc == rxCrc.getCRCBitrev() ? 0x80 : 0); // FIFOP should not be set if CRC is not ok??? - depends on autoCRC! - setFIFOP(true); + /* set FIFOP only if this is the first received packet + * TODO: check what happens when rxfifoLen < rxlen - e.g we have been reading before FIFOP + * fix support for FIFOP threshold */ + if (rxfifoLen <= rxlen) { + setFIFOP(true); + } setSFD(false); - lastPacketStart = (rxfifoWritePos + 128 - rxlen) & 127; if (DEBUG) log("RX: Complete: packetStart: " + lastPacketStart + " rxPStart: " + rxPacketStart); @@ -763,10 +767,18 @@ (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) + " size: " + rxfifoLen); source.byteReceived( (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) ); - rxfifoReadPos = (rxfifoReadPos + 1) & 127; - if (rxfifoLen > 0) { - rxfifoLen--; + /* initiate read of another packet */ + if (rxfifoReadLeft == 0) { + rxfifoReadLeft = (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF); + } else if (--rxfifoReadLeft == 0) { + /* check if we have another complete packet in buffer... */ + if (rxfifoLen > 1 && rxfifoLen >= (memory[RAM_RXFIFO + (rxfifoReadPos + 1) & 127] & 0xFF) + 1) { + if (!overflow) setFIFOP(true); + } + } + rxfifoReadPos = (rxfifoReadPos + 1) & 127; + rxfifoLen--; } // Set the FIFO pin low if there are no more bytes available in the RXFIFO. if(rxfifoLen == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-26 14:26:45
|
Revision: 683 http://mspsim.svn.sourceforge.net/mspsim/?rev=683&view=rev Author: joxe Date: 2010-03-26 14:26:37 +0000 (Fri, 26 Mar 2010) Log Message: ----------- fixed bug in watchdog timer Modified Paths: -------------- mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/Watchdog.java Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2010-03-26 13:13:57 UTC (rev 682) +++ mspsim/se/sics/mspsim/core/SFR.java 2010-03-26 14:26:37 UTC (rev 683) @@ -46,7 +46,7 @@ */ public class SFR extends IOUnit { - private boolean DEBUG = false;//true; + private boolean DEBUG = false; public static final int IE1 = 0; public static final int IE2 = 1; @@ -110,7 +110,7 @@ switch (address) { case IE1: case IE2: - updateIE(address - IE1, value); + updateIE(address - IE1, value); break; case IFG1: case IFG2: @@ -200,12 +200,12 @@ if (sfrModule[pos] != null && !irqTriggered[irqVector[pos]]) { /* interrupt goes directly to the module responsible */ if (DEBUG) System.out.println("SFR: flagging interrupt: " + - sfrModule[pos].getName() + " pos: " + pos + " " + (ie & ifg & 1) + " chg: " + change); + sfrModule[pos].getName() + " pos: " + pos + " ie: " + (ie & 1) + " ifg:" + (ifg & 1) + " chg: " + change); if ((ie & ifg & 1) > 0) { int vector = irqVector[pos]; irqTriggered[vector] = true; irqTriggeredPos[vector] = pos; - cpu.flagInterrupt(irqVector[pos], this, true); + cpu.flagInterrupt(vector, this, true); } // cpu.flagInterrupt(irqVector[pos], sfrModule[pos], (ie & ifg & 1) > 0); } @@ -261,6 +261,9 @@ } else { ifg2 &= ~(1 << bit); } + if (DEBUG) { + System.out.println("SFR: cleared interrupt for " + sfrModule[pos] + " vector: " + vector); + } } cpu.flagInterrupt(vector, this, false); if (sfrModule[pos] != null) { Modified: mspsim/se/sics/mspsim/core/Watchdog.java =================================================================== --- mspsim/se/sics/mspsim/core/Watchdog.java 2010-03-26 13:13:57 UTC (rev 682) +++ mspsim/se/sics/mspsim/core/Watchdog.java 2010-03-26 14:26:37 UTC (rev 683) @@ -59,6 +59,7 @@ private static final int WATCHDOG_VECTOR = 10; private static final int WATCHDOG_INTERRUPT_BIT = 0; + private static final int WATCHDOG_INTERRUPT_VALUE = 1 << WATCHDOG_INTERRUPT_BIT; private static final int RESET_VECTOR = 15; private static final int[] DELAY = { @@ -105,7 +106,7 @@ // Here the WDT triggered!!! if (timerMode) { SFR sfr = cpu.getSFR(); - sfr.setBitIFG(0, WATCHDOG_INTERRUPT_BIT); + sfr.setBitIFG(0, WATCHDOG_INTERRUPT_VALUE); scheduleTimer(); } else { System.out.println("WDT trigger - will reset node!"); @@ -148,6 +149,7 @@ } } } + private void scheduleTimer() { if (sourceACLK) { if (DEBUG) System.out.println("setting delay in ms (ACLK): " + 1000.0 * delay / cpu.aclkFrq); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-26 13:14:03
|
Revision: 682 http://mspsim.svn.sourceforge.net/mspsim/?rev=682&view=rev Author: joxe Date: 2010-03-26 13:13:57 +0000 (Fri, 26 Mar 2010) Log Message: ----------- added timer feature to watchdog Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Watchdog.java mspsim/se/sics/mspsim/util/ELF.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2010-03-24 20:41:39 UTC (rev 681) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2010-03-26 13:13:57 UTC (rev 682) @@ -149,10 +149,6 @@ memIn[0x180 + i] = tb; } - Watchdog wdt = new Watchdog(this); - memOut[0x120] = wdt; - memIn[0x120] = wdt; - /* TODO: this range is only valid for the F1611 series (Sky, etc) */ flash = new Flash(this, memory, new FlashRange(0x4000, 0x10000, 512, 64), @@ -167,6 +163,9 @@ memOut[i] = sfr; memIn[i] = sfr; } + Watchdog wdt = new Watchdog(this); + memOut[0x120] = wdt; + memIn[0x120] = wdt; memIn[Timer.TAIV] = ta; memOut[Timer.TAIV] = ta; Modified: mspsim/se/sics/mspsim/core/Watchdog.java =================================================================== --- mspsim/se/sics/mspsim/core/Watchdog.java 2010-03-24 20:41:39 UTC (rev 681) +++ mspsim/se/sics/mspsim/core/Watchdog.java 2010-03-26 13:13:57 UTC (rev 682) @@ -46,16 +46,19 @@ * @author joakim * */ -public class Watchdog extends IOUnit { +public class Watchdog extends IOUnit implements SFRModule { private static final boolean DEBUG = false; private static final int WDTCTL = 0x120; private static final int WDTHOLD = 0x80; private static final int WDTCNTCL = 0x08; + private static final int WDTMSEL = 0x10; private static final int WDTSSEL = 0x04; private static final int WDTISx = 0x03; + private static final int WATCHDOG_VECTOR = 10; + private static final int WATCHDOG_INTERRUPT_BIT = 0; private static final int RESET_VECTOR = 15; private static final int[] DELAY = { @@ -74,6 +77,8 @@ // Timer ACLK private boolean sourceACLK = false; + // Timer or WDT mode + private boolean timerMode = false; private TimeEvent wdtTrigger = new TimeEvent(0, "Watchdog") { public void execute(long t) { @@ -85,6 +90,7 @@ public Watchdog(MSP430Core cpu) { super(cpu.memory, 0x120); this.cpu = cpu; + cpu.getSFR().registerSFDModule(0, WATCHDOG_INTERRUPT_BIT, this, WATCHDOG_VECTOR); } public String getName() { @@ -92,14 +98,20 @@ } public void interruptServiced(int vector) { - cpu.flagInterrupt(RESET_VECTOR, this, false); + cpu.flagInterrupt(vector, this, false); } private void triggerWDT(long time) { - // Here the WDT triggered!!! - System.out.println("WDT trigger - will reset node!"); - cpu.generateTrace(System.out); - cpu.flagInterrupt(RESET_VECTOR, this, true); + // Here the WDT triggered!!! + if (timerMode) { + SFR sfr = cpu.getSFR(); + sfr.setBitIFG(0, WATCHDOG_INTERRUPT_BIT); + scheduleTimer(); + } else { + System.out.println("WDT trigger - will reset node!"); + cpu.generateTrace(System.out); + cpu.flagInterrupt(RESET_VECTOR, this, true); + } } public int read(int address, boolean word, long cycles) { @@ -120,16 +132,11 @@ // Clear timer => reset the delay delay = DELAY[value & WDTISx]; } + timerMode = (value & WDTMSEL) != 0; // Start it if it should be started! if (wdtOn) { if (DEBUG) System.out.println("Setting WDTCNT to count: " + delay); - if (sourceACLK) { - if (DEBUG) System.out.println("setting delay in ms (ACLK): " + 1000.0 * delay / cpu.aclkFrq); - targetTime = cpu.scheduleTimeEventMillis(wdtTrigger, 1000.0 * delay / cpu.aclkFrq); - } else { - if (DEBUG) System.out.println("setting delay in cycles"); - cpu.scheduleCycleEvent(wdtTrigger, targetTime = cpu.cycles + delay); - } + scheduleTimer(); } else { // Stop it and remember current "delay" left! wdtTrigger.remove(); @@ -141,5 +148,17 @@ } } } + private void scheduleTimer() { + if (sourceACLK) { + if (DEBUG) System.out.println("setting delay in ms (ACLK): " + 1000.0 * delay / cpu.aclkFrq); + targetTime = cpu.scheduleTimeEventMillis(wdtTrigger, 1000.0 * delay / cpu.aclkFrq); + } else { + if (DEBUG) System.out.println("setting delay in cycles"); + cpu.scheduleCycleEvent(wdtTrigger, targetTime = cpu.cycles + delay); + } + } + public void enableChanged(int reg, int bit, boolean enabled) { + System.out.println("*** Watchdog module enabled: " + enabled); + } } Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2010-03-24 20:41:39 UTC (rev 681) +++ mspsim/se/sics/mspsim/util/ELF.java 2010-03-26 13:13:57 UTC (rev 682) @@ -44,7 +44,6 @@ import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-24 20:41:45
|
Revision: 681 http://mspsim.svn.sourceforge.net/mspsim/?rev=681&view=rev Author: joxe Date: 2010-03-24 20:41:39 +0000 (Wed, 24 Mar 2010) Log Message: ----------- improved CC2420 and timer emulation - patches submitted by Philipp Sommer Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-24 07:53:31 UTC (rev 680) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-24 20:41:39 UTC (rev 681) @@ -266,6 +266,8 @@ private boolean shouldAck = false; private boolean addressDecode = false; private boolean autoCRC = false; + private int dsn = 0; + private int activeFrequency = 0; private int activeChannel = 0; @@ -567,6 +569,9 @@ decodeAddress = addressDecode & (memory[RAM_RXFIFO + rxPacketStart] & ACK_REQUEST) > 0; destinationAddressMode = (memory[RAM_RXFIFO + ((rxPacketStart + 1) & 127)] >> 2) & 3; } + } else if (rxread == 3) { + // save data sequence number + dsn = data & 0xff; } if (decodeAddress) { boolean flushPacket = false; @@ -926,6 +931,9 @@ //log("Strobe Oscillator Off"); stopOscillator(); break; + case REG_SACK: + setState(RadioState.TX_ACK_CALIBRATE); + break; default: if (DEBUG) { log("Unknown strobe command: " + data); @@ -998,7 +1006,9 @@ if (ackPos < ackBuf.length) { if(ackPos == 0) { txCrc.setCRC(0); - int len = 3; + // set dsn + ackBuf[3] = dsn; + int len = 4; for (int i = 1; i < len; i++) { txCrc.addBitrev(ackBuf[i] & 0xff); } Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2010-03-24 07:53:31 UTC (rev 680) +++ mspsim/se/sics/mspsim/core/Timer.java 2010-03-24 20:41:39 UTC (rev 681) @@ -920,6 +920,10 @@ (value == IOPort.PIN_LOW && fall)) { // System.out.println("*** Capture on CCR_" + ccrIndex + " " + " value: " + // value); + // update counter values and compare register + updateCounter(core.cycles); + reg.tccr = counter; + // Set the interrupt flag... reg.tcctl |= CC_IFG; reg.triggerInterrupt(core.cycles); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-24 07:53:38
|
Revision: 680 http://mspsim.svn.sourceforge.net/mspsim/?rev=680&view=rev Author: joxe Date: 2010-03-24 07:53:31 +0000 (Wed, 24 Mar 2010) Log Message: ----------- updated GDBStubs server based on input from M.Struebe Modified Paths: -------------- mspsim/se/sics/mspsim/util/GDBStubs.java Modified: mspsim/se/sics/mspsim/util/GDBStubs.java =================================================================== --- mspsim/se/sics/mspsim/util/GDBStubs.java 2010-03-23 15:28:45 UTC (rev 679) +++ mspsim/se/sics/mspsim/util/GDBStubs.java 2010-03-24 07:53:31 UTC (rev 680) @@ -39,6 +39,7 @@ * $Revision:$ */ package se.sics.mspsim.util; + import java.io.DataInputStream; import java.io.IOException; import java.io.OutputStream; @@ -50,150 +51,202 @@ public class GDBStubs implements Runnable { - private final static String OK = "OK"; + private final static String OK = "OK"; - ServerSocket serverSocket; - OutputStream output; - MSP430Core cpu; - - public void setupServer(MSP430Core cpu, int port) { - this.cpu = cpu; - try { - serverSocket = new ServerSocket(port); - System.out.println("GDBStubs open server socket port: " + port); - new Thread(this).start(); - } catch (IOException e) { - e.printStackTrace(); + ServerSocket serverSocket; + OutputStream output; + MSP430Core cpu; + + public void setupServer(MSP430Core cpu, int port) { + this.cpu = cpu; + try { + serverSocket = new ServerSocket(port); + System.out.println("GDBStubs open server socket port: " + port); + new Thread(this).start(); + } catch (IOException e) { + e.printStackTrace(); + } } - } - int[] buffer = new int[256]; - int len; - public void run() { - while (true) { - try { - Socket s = serverSocket.accept(); + int[] buffer = new int[256]; + int len; - DataInputStream input = new DataInputStream(s.getInputStream()); - output = s.getOutputStream(); + public void run() { + while (true) { + try { + Socket s = serverSocket.accept(); - String cmd = ""; - boolean readCmd = false; - int c; - while (s != null && ((c = input.read()) != -1)) { - System.out.println("GDBStubs: Read " + c + " => " + (char) c); - if (c == '#') { - readCmd = false; - /* ack the message */ - output.write('+'); - handleCmd(cmd, buffer, len); - cmd = ""; - len = 0; - } - if (readCmd) { - cmd += (char) c; - buffer[len++] = (c & 0xff); - } - if (c == '$') { - readCmd = true; - } + DataInputStream input = new DataInputStream(s.getInputStream()); + output = s.getOutputStream(); + + String cmd = ""; + boolean readCmd = false; + int c; + while (s != null && ((c = input.read()) != -1)) { + System.out.println("GDBStubs: Read " + c + " => " + + (char) c); + if (c == '#') { + readCmd = false; + /* ack the message */ + output.write('+'); + handleCmd(cmd, buffer, len); + cmd = ""; + len = 0; + } + if (readCmd) { + cmd += (char) c; + buffer[len++] = (c & 0xff); + } + if (c == '$') { + readCmd = true; + } + } + } catch (IOException e) { + e.printStackTrace(); + } catch (EmulationException e) { + e.printStackTrace(); + } } - } catch (IOException e) { - e.printStackTrace(); - } catch (EmulationException e) { - e.printStackTrace(); - } } - } - private void handleCmd(String cmd, int[] cmdBytes, int cmdLen) throws IOException, - EmulationException { - System.out.println("cmd: " + cmd); - char c = cmd.charAt(0); - switch(c) { - case 'H': - sendResponse(OK); - break; - case 'q': - if ("qC".equals(cmd)) { - sendResponse("QC1"); - } else if ("qOffsets".equals(cmd)) { - sendResponse("Text=000;Data=000;Bss=000;"); - } - break; - case '?': - sendResponse("S01"); - break; - case 'g': - readRegisters(); - break; - case 'k': // kill - sendResponse(OK); - break; - case 'm': - case 'M': - case 'X': - String cmd2 = cmd.substring(1); - String wdata[] = cmd2.split(":"); - int cPos = cmd.indexOf(':'); - if (cPos > 0) { - /* only until length in first part */ - cmd2 = wdata[0]; - } - String parts[] = cmd2.split(","); - int addr = Integer.decode("0x" + parts[0]); - int len = Integer.decode("0x" + parts[1]); - String data = ""; - if (c =='m') { - System.out.println("Returning memory from: " + addr + " len = " + len); - /* This might be wrong - which is the correct byte order? */ - for (int i = 0; i < len; i++) { - data += Utils.hex8(cpu.memory[addr++] & 0xff); + private void handleCmd(String cmd, int[] cmdBytes, int cmdLen) + throws IOException, EmulationException { + System.out.println("cmd: " + cmd); + char c = cmd.charAt(0); + switch (c) { + case 'H': + sendResponse(OK); + break; + case 'q': + if ("qC".equals(cmd)) { + sendResponse("QC1"); + } else if ("qOffsets".equals(cmd)) { + sendResponse("Text=0;Data=0;Bss=0"); + } else if ("qfThreadInfo".equals(cmd)){ + sendResponse("m 01"); + } else if ("qsThreadInfo".equals(cmd)){ + sendResponse("l"); + } else if ("qSymbol::".equals(cmd)){ + sendResponse(OK); + //} else if ("qThreadExtraInfo,1".equals(cmd)){ + // sendResponse(stringToHex("Stoped")); + } else { + System.out.println("Command unknown"); + sendResponse(""); + } + + break; + case '?': + sendResponse("S01"); + break; + case 'g': + readRegisters(); + break; + case 'k': // kill + sendResponse(OK); + break; + case 'm': + case 'M': + case 'X': + String cmd2 = cmd.substring(1); + String wdata[] = cmd2.split(":"); + int cPos = cmd.indexOf(':'); + if (cPos > 0) { + /* only until length in first part */ + cmd2 = wdata[0]; + } + String parts[] = cmd2.split(","); + int addr = Integer.decode("0x" + parts[0]); + int len = Integer.decode("0x" + parts[1]); + String data = ""; + if (c == 'm') { + System.out.println("Returning memory from: " + addr + " len = " + + len); + /* This might be wrong - which is the correct byte order? */ + for (int i = 0; i < len; i++) { + data += Utils.hex8(cpu.memory[addr++] & 0xff); + } + sendResponse(data); + } else { + System.out.println("Writing to memory at: " + addr + " len = " + + len + " with: " + + ((wdata.length > 1) ? wdata[1] : "")); + cPos++; + for (int i = 0; i < len; i++) { + System.out.println("Writing: " + cmdBytes[cPos] + " to " + + addr + " cpos=" + cPos); + cpu.write(addr++, cmdBytes[cPos++], false); + } + sendResponse(OK); + } + break; + case 'C': + sendResponse("S01"); + break; + default: + System.out.println("Command unknown"); + sendResponse(""); } - sendResponse(data); - } else { - System.out.println("Writing to memory at: " + addr + " len = " + len + - " with: " + ((wdata.length > 1) ? wdata[1] : "")); - cPos++; - for (int i = 0; i < len; i++) { - System.out.println("Writing: " + cmdBytes[cPos] + " to " + addr + " cpos=" + cPos); - cpu.write(addr++, cmdBytes[cPos++], false); + } + + private void readRegisters() throws IOException { + String regs = ""; + for (int i = 0; i < 16; i++) { + regs += Utils.hex8(cpu.reg[i] & 0xff) + Utils.hex8(cpu.reg[i] >> 8); } - sendResponse(OK); - } - break; + sendResponse(regs); } - } - private void readRegisters() throws IOException { - String regs = ""; - for (int i = 0; i < 16; i++) { - regs += Utils.hex8(cpu.reg[i] & 0xff) + Utils.hex8(cpu.reg[i] >> 8); + public static String stringToHex(String base) + { + StringBuffer buffer = new StringBuffer(); + int intValue; + for(int x = 0; x < base.length(); x++) + { + int cursor = 0; + intValue = base.charAt(x); + String binaryChar = new String(Integer.toBinaryString(base.charAt(x))); + for(int i = 0; i < binaryChar.length(); i++) { + if(binaryChar.charAt(i) == '1') { + cursor += 1; + } + } + if((cursor % 2) > 0) { + intValue += 128; + } + buffer.append(Integer.toHexString(intValue)); + } + return buffer.toString(); } - sendResponse(regs); - } - public void sendResponse(String resp) throws IOException { - output.write('$'); - int cs = 0; - if (resp != null) { - for (int i = 0; i < resp.length(); i++) { - output.write((char) resp.charAt(i)); - System.out.print(resp.charAt(i)); - cs += resp.charAt(i); - } + + public void sendResponse(String resp) throws IOException { + output.write('$'); + int cs = 0; + if (resp != null) { + for (int i = 0; i < resp.length(); i++) { + output.write((char) resp.charAt(i)); + System.out.print(resp.charAt(i)); + cs += resp.charAt(i); + } + } + output.write('#'); + System.out.print('#'); + int c = (cs & 0xff) >> 4; + if (c < 10) { + c = c + '0'; + } else { + c = c - 10 + 'a'; + } + output.write((char) c); + System.out.print((char) c); + c = cs & 15; + if (c < 10) { + c = c + '0'; + } else { + c = c - 10 + 'a'; + } + output.write((char) c); + System.out.println((char) c); } - output.write('#'); - System.out.print('#'); - int c = (cs & 0xff) >> 4; - if (c < 10) c = c + '0'; - else c = c - 10 + 'a'; - output.write((char)c); - System.out.print((char)c); - c = cs & 15; - if (c < 10) c = c + '0'; - else c = c - 10 + 'a'; - output.write((char)c); - System.out.println((char)c); - } -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fro...@us...> - 2010-03-23 15:29:00
|
Revision: 679 http://mspsim.svn.sourceforge.net/mspsim/?rev=679&view=rev Author: fros4943 Date: 2010-03-23 15:28:45 +0000 (Tue, 23 Mar 2010) Log Message: ----------- removed test code Modified Paths: -------------- mspsim/se/sics/mspsim/chip/SHT11.java Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2010-03-23 12:49:01 UTC (rev 678) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2010-03-23 15:28:45 UTC (rev 679) @@ -125,9 +125,6 @@ /* Something bad has happened */ return; } - - temp += 1; - humid += 1; int crc = 0; crc = crc8Add(crc, readData); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-23 12:49:08
|
Revision: 678 http://mspsim.svn.sourceforge.net/mspsim/?rev=678&view=rev Author: joxe Date: 2010-03-23 12:49:01 +0000 (Tue, 23 Mar 2010) Log Message: ----------- bugfix of CRC in SHT11 Modified Paths: -------------- mspsim/se/sics/mspsim/chip/SHT11.java Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2010-03-21 18:52:25 UTC (rev 677) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2010-03-23 12:49:01 UTC (rev 678) @@ -86,25 +86,25 @@ private MSP430Core cpu; - private int rev8bits(int v) { + private static int rev8bits(int v) { int r = 0; - int s = 7; + int s = 8; - for (v >>= 1; v > 0; v >>= 1) { - r <<= 1; - r |= v & 1; + while(v > 0) { + r = (r << 1) | v & 1; + v = (v >> 1) & 0xff; s--; } r <<= s; /* Shift when v's highest bits are zero */ - return r; + return r & 0xff; } private int crc8Add(int acc, int data) { int i; - acc ^= data; + acc ^= (data & 0xff); for(i = 0; i < 8; i++) { if((acc & 0x80) != 0) { - acc = (acc << 1) ^ 0x31; + acc = ((acc << 1) ^ 0x31) & 0xff; } else { acc <<= 1; } @@ -116,20 +116,25 @@ private TimeEvent measureEvent = new TimeEvent(0) { public void execute(long t) { if (readData == CMD_MEASURE_TEMP) { - output[0] = temp >> 8; + output[0] = (temp >> 8) & 0xff; output[1] = temp & 0xff; } else if (readData == CMD_MEASURE_HUM) { - output[0] = humid >> 8; + output[0] = (humid >> 8) & 0xff; output[1] = humid & 0xff; } else { /* Something bad has happened */ return; } + + temp += 1; + humid += 1; + int crc = 0; crc = crc8Add(crc, readData); crc = crc8Add(crc, output[0]); crc = crc8Add(crc, output[1]); - if (DEBUG) System.out.println("CRC: " + crc + " rcrc: " + rev8bits(crc)); + if (DEBUG) System.out.println("CRC: " + + Utils.hex8(crc) + " rcrc: " + Utils.hex8(rev8bits(crc))); output[2] = rev8bits(crc); /* finished measuring - signal with LOW! */ @@ -285,6 +290,5 @@ public String getName() { return "SHT11"; - } - + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-21 18:52:32
|
Revision: 677 http://mspsim.svn.sourceforge.net/mspsim/?rev=677&view=rev Author: joxe Date: 2010-03-21 18:52:25 +0000 (Sun, 21 Mar 2010) Log Message: ----------- added emulation exceptions for illegal CCR/TL access Modified Paths: -------------- mspsim/se/sics/mspsim/core/Timer.java Modified: mspsim/se/sics/mspsim/core/Timer.java =================================================================== --- mspsim/se/sics/mspsim/core/Timer.java 2010-03-17 21:55:25 UTC (rev 676) +++ mspsim/se/sics/mspsim/core/Timer.java 2010-03-21 18:52:25 UTC (rev 677) @@ -524,6 +524,9 @@ case TCCR5: case TCCR6: i = (index - TCCR0) / 2; + if (i >= noCompare) { + throw new EmulationException(getName() + " Reading from CCR register that is not available " + i); + } val = ccr[i].tccr; break; default: @@ -543,6 +546,9 @@ * and other dynamic values */ private void updateTCCTL(int cctl, long cycles) { + if (cctl >= noCompare) { + throw new EmulationException(getName() + " Trying to write to non-existent CCTL register: " + cctl); + } // update the CCI depending on speed of clocks... boolean input = false; /* if ACLK we can calculate edge... */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-17 21:55:31
|
Revision: 676 http://mspsim.svn.sourceforge.net/mspsim/?rev=676&view=rev Author: joxe Date: 2010-03-17 21:55:25 +0000 (Wed, 17 Mar 2010) Log Message: ----------- fixed CRC check in CC2420 Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-17 20:23:06 UTC (rev 675) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-17 21:55:25 UTC (rev 676) @@ -558,7 +558,7 @@ if (DEBUG) log("RX: Start frame length " + rxlen); // FIFO pin goes high after length byte is written to RXFIFO setFIFO(true); - } else if (rxread < rxlen - 2) { + } else if (rxread < rxlen - 1) { /* As long as we are not in the length or FCF (CRC) we count CRC */ rxCrc.addBitrev(data & 0xff); @@ -617,13 +617,14 @@ int crc = memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)] << 8; crc += memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)]; - if (DEBUG && crc != rxCrc.getCRCBitrev()) { - log("CRC not OK: recv:" + crc + " calc: " + Utils.hex16(rxCrc.getCRCBitrev())); + if (true && crc != rxCrc.getCRCBitrev()) { + System.out.println("CRC not OK: recv:" + Utils.hex16(crc) + " calc: " + Utils.hex16(rxCrc.getCRCBitrev())); } // Should take a RSSI value as input or use a set-RSSI value... memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)] = (registers[REG_RSSI]) & 0xff; // Set CRC ok and add a correlation - TODO: fix better correlation value!!! - memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)] = 37 | (crc == rxCrc.getCRCBitrev() ? 0x80 : 0); + memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)] = 37 | + (crc == rxCrc.getCRCBitrev() ? 0x80 : 0); // FIFOP should not be set if CRC is not ok??? - depends on autoCRC! setFIFOP(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-17 20:23:12
|
Revision: 675 http://mspsim.svn.sourceforge.net/mspsim/?rev=675&view=rev Author: joxe Date: 2010-03-17 20:23:06 +0000 (Wed, 17 Mar 2010) Log Message: ----------- fixed CC2420 CRC Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/util/CCITT_CRC.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-12 14:20:17 UTC (rev 674) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-17 20:23:06 UTC (rev 675) @@ -560,7 +560,7 @@ setFIFO(true); } else if (rxread < rxlen - 2) { /* As long as we are not in the length or FCF (CRC) we count CRC */ - rxCrc.add(data & 0xff); + rxCrc.addBitrev(data & 0xff); if (rxread == 2) { if (TYPE_DATA_FRAME == (memory[RAM_RXFIFO + rxPacketStart] & FRAME_TYPE)) { @@ -617,13 +617,13 @@ int crc = memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)] << 8; crc += memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)]; - if (DEBUG && crc != rxCrc.getCRC()) { - log("CRC not OK: recv:" + crc + " calc: " + rxCrc.getCRC()); + if (DEBUG && crc != rxCrc.getCRCBitrev()) { + log("CRC not OK: recv:" + crc + " calc: " + Utils.hex16(rxCrc.getCRCBitrev())); } // Should take a RSSI value as input or use a set-RSSI value... memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)] = (registers[REG_RSSI]) & 0xff; // Set CRC ok and add a correlation - TODO: fix better correlation value!!! - memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)] = 37 | (crc == rxCrc.getCRC() ? 0x80 : 0); + memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)] = 37 | (crc == rxCrc.getCRCBitrev() ? 0x80 : 0); // FIFOP should not be set if CRC is not ok??? - depends on autoCRC! setFIFOP(true); @@ -961,15 +961,11 @@ if (txfifoPos == 0) { txCrc.setCRC(0); int len = memory[RAM_TXFIFO] & 0xff; - for (int i = 1; i < len - 2; i++) { - txCrc.add(memory[RAM_TXFIFO + i] & 0xff); + for (int i = 1; i < len - 1; i++) { + txCrc.addBitrev(memory[RAM_TXFIFO + i] & 0xff); } -// System.out.println("Setting TX CRC to: " + txCrc.getCRC()); - /* this is not correct - will probably not be compliant with the order - * that the actual CC2420 sends the CRC... - */ - memory[RAM_TXFIFO + len - 1] = txCrc.getCRC() >> 8; - memory[RAM_TXFIFO + len] = txCrc.getCRC() & 0xff; + memory[RAM_TXFIFO + len - 1] = txCrc.getCRCHi(); + memory[RAM_TXFIFO + len] = txCrc.getCRCLow(); } if (txfifoPos > 0x7f) { log("Warning: packet size too large - repeating packet bytes txfifoPos: " + txfifoPos); @@ -1003,14 +999,10 @@ txCrc.setCRC(0); int len = 3; for (int i = 1; i < len; i++) { - txCrc.add(ackBuf[i] & 0xff); + txCrc.addBitrev(ackBuf[i] & 0xff); } - // System.out.println("Setting TX CRC to: " + txCrc.getCRC()); - /* this is not correct - will probably not be compliant with the order - * that the actual CC2420 sends the CRC... - */ - ackBuf[4] = txCrc.getCRC() >> 8; - ackBuf[5] = txCrc.getCRC() & 0xff; + ackBuf[4] = txCrc.getCRCHi(); + ackBuf[5] = txCrc.getCRCLow(); } if (listener != null) { if (DEBUG) log("transmitting byte: " + Utils.hex8(memory[RAM_TXFIFO + (txfifoPos & 0x7f)] & 0xFF)); Modified: mspsim/se/sics/mspsim/util/CCITT_CRC.java =================================================================== --- mspsim/se/sics/mspsim/util/CCITT_CRC.java 2010-03-12 14:20:17 UTC (rev 674) +++ mspsim/se/sics/mspsim/util/CCITT_CRC.java 2010-03-17 20:23:06 UTC (rev 675) @@ -41,23 +41,67 @@ public int getCRC() { return crc; } - + + /* this will only work with zero... */ public void setCRC(int val) { - crc = val; + crc = val; } public void clr() { crc = 0xffff; } + + public void addBitrev(int data) { + add(bitrev(data)); + } + public int getCRCLow() { + return bitrev(crc & 0xff); + } + + public int getCRCHi() { + return bitrev(crc >> 8); + } + + public int add(int data) { - int newCrc = (crc >> 8) | (crc << 8) & 0xffff; - newCrc ^= data & 0xff; + int newCrc = ((crc >> 8) & 0xff) | (crc << 8) & 0xffff; + newCrc ^= (data & 0xff); newCrc ^= (newCrc & 0xff) >> 4; - newCrc ^= (newCrc << 12); + newCrc ^= (newCrc << 12) & 0xffff; newCrc ^= (newCrc & 0xff) << 5; crc = newCrc & 0xffff; return crc; } + + public int getCRCBitrev() { + return getCRCLow() + (getCRCHi() << 8); + } + public static final String hex = "0123456789abcdef"; + + private static int bitrev(int data) { + return ((data << 7) & 0x80) | ((data << 5) & 0x40) | + (data << 3) & 0x20 | (data << 1) & 0x10 | + (data >> 7) & 0x01 | (data >> 5) & 0x02 | + (data >> 3) & 0x04 | (data >> 1) & 0x08; + } + + public static void main(String[] args) { + CCITT_CRC crc = new CCITT_CRC(); + crc.setCRC(0x0); + + String packet = "41c8a7cdabffff777777feff7777027b493a0201ff777777870015d300000000fe80000000000000007777fffe777777"; + packet = "41cc39adba020202000274120007070700077412007b333a8700939800000000fe80000000000000021274020002020201020012740700070707000000000000"; + packet = "41c816adbaffff09090900097412007a3b3a029b02d1f5e0000011aaaa00000000000002127401000101010500020000040005080a011004"; + for (int i = 0; i < packet.length(); i += 2) { + int data = (hex.indexOf(packet.charAt(i)) << 4) + hex.indexOf(packet.charAt(i + 1)); + crc.addBitrev(data); + } + + //0x901d + System.out.println("CRC: " + Utils.hex8(crc.getCRCHi()) + Utils.hex8(crc.getCRCLow())); + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-12 14:20:24
|
Revision: 674 http://mspsim.svn.sourceforge.net/mspsim/?rev=674&view=rev Author: joxe Date: 2010-03-12 14:20:17 +0000 (Fri, 12 Mar 2010) Log Message: ----------- added interface for setting temp and humid Modified Paths: -------------- mspsim/se/sics/mspsim/chip/SHT11.java Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2010-03-09 18:03:14 UTC (rev 673) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2010-03-12 14:20:17 UTC (rev 674) @@ -140,6 +140,15 @@ writeLen = 3; }}; + + public void setTemperature(int temp) { + this.temp = temp; + } + + public void setHumidity(int humidity) { + this.humid = humidity; + } + // TODO: super(cpu) and chip autoregister chips into the CPU. public SHT11(MSP430Core core) { cpu = core; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-03-09 18:03:21
|
Revision: 673 http://mspsim.svn.sourceforge.net/mspsim/?rev=673&view=rev Author: nifi Date: 2010-03-09 18:03:14 +0000 (Tue, 09 Mar 2010) Log Message: ----------- Added method resetProfile() to Profiler for notifying profilers about CPU reset Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/Profiler.java mspsim/se/sics/mspsim/util/SimpleProfiler.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2010-03-09 12:15:05 UTC (rev 672) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2010-03-09 18:03:14 UTC (rev 673) @@ -583,7 +583,7 @@ resetIOUnits(); if (profiler != null) { - profiler.clearProfile(); + profiler.resetProfile(); } } Modified: mspsim/se/sics/mspsim/core/Profiler.java =================================================================== --- mspsim/se/sics/mspsim/core/Profiler.java 2010-03-09 12:15:05 UTC (rev 672) +++ mspsim/se/sics/mspsim/core/Profiler.java 2010-03-09 18:03:14 UTC (rev 673) @@ -58,7 +58,8 @@ public void profileReturn(long cycles); public void profileInterrupt(int vector, long cycles); public void profileRETI(long cycles); - + + public void resetProfile(); public void clearProfile(); public void addCallListener(CallListener listener); Modified: mspsim/se/sics/mspsim/util/SimpleProfiler.java =================================================================== --- mspsim/se/sics/mspsim/util/SimpleProfiler.java 2010-03-09 12:15:05 UTC (rev 672) +++ mspsim/se/sics/mspsim/util/SimpleProfiler.java 2010-03-09 18:03:14 UTC (rev 673) @@ -224,7 +224,12 @@ /* what if interrupt from interrupt ? */ servicedInterrupt = -1; } - + + public void resetProfile() { + clearProfile(); + cSP = 0; + } + public void clearProfile() { if (profileData != null) { CallEntry[] entries = @@ -241,6 +246,7 @@ } } } + public void printProfile(PrintStream out) { printProfile(out, new Properties()); } @@ -322,9 +328,10 @@ } public void printStackTrace(PrintStream out) { - out.println("Stack Trace: number of calls: " + cSP); - for (int i = 0; i < cSP; i++) { - out.println(" " + callStack[cSP - i - 1].function.getInfo()); + int stackCount = cSP; + out.println("Stack Trace: number of calls: " + stackCount); + for (int i = 0; i < stackCount; i++) { + out.println(" " + callStack[stackCount - i - 1].function.getInfo()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-09 12:15:14
|
Revision: 672 http://mspsim.svn.sourceforge.net/mspsim/?rev=672&view=rev Author: joxe Date: 2010-03-09 12:15:05 +0000 (Tue, 09 Mar 2010) Log Message: ----------- fixed edge-detect IRQ flag behavior to be correct Modified Paths: -------------- mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2010-03-06 08:30:21 UTC (rev 671) +++ mspsim/se/sics/mspsim/core/SFR.java 2010-03-09 12:15:05 UTC (rev 672) @@ -68,12 +68,14 @@ private SFRModule[] sfrModule = new SFRModule[16]; private int[] irqVector = new int[16]; private boolean[] irqTriggered = new boolean[16]; + private boolean[] autoclear = new boolean[16]; private int[] irqTriggeredPos = new int[16]; public SFR(MSP430Core cpu, int[] memory) { super(memory, 0); this.cpu = cpu; this.memory = memory; + reset(0); } public void reset(int type) { @@ -83,8 +85,10 @@ ifg2 = 0; me1 = 0; me2 = 0; + /* no IRQ - but all are autoclear */ for (int i = 0; i < irqTriggered.length; i++) { irqTriggered[i] = false; + autoclear[i] = true; } } @@ -241,15 +245,22 @@ else return ifg2; } + public void setAutoclear(int vector, boolean b) { + autoclear[vector] = b; + } + + public void interruptServiced(int vector) { irqTriggered[vector] = false; - /* clear the bits that correspond to this vector! */ int pos = irqTriggeredPos[vector]; - int bit = pos & 7; - if (pos < 8) { - ifg1 &= ~(1 << bit); - } else { - ifg2 &= ~(1 << bit); + if (autoclear[vector]) { + /* clear the bits that correspond to this vector! */ + int bit = pos & 7; + if (pos < 8) { + ifg1 &= ~(1 << bit); + } else { + ifg2 &= ~(1 << bit); + } } cpu.flagInterrupt(vector, this, false); if (sfrModule[pos] != null) { @@ -260,4 +271,5 @@ public String getName() { return "SpecialFunctionRegister, SFR"; } + } // SFR Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2010-03-06 08:30:21 UTC (rev 671) +++ mspsim/se/sics/mspsim/core/USART.java 2010-03-09 12:15:05 UTC (rev 672) @@ -41,8 +41,6 @@ package se.sics.mspsim.core; -import org.jfree.chart.needle.ShipNeedle; - public class USART extends IOUnit implements SFRModule { public static final boolean DEBUG = false; //true; @@ -80,9 +78,11 @@ public static final int USART1_RX_BIT = 4; public static final int USART1_TX_BIT = 5; + + // Flags. public static final int UTCTL_TXEMPTY = 0x01; - + public static final int UTCTL_URXSE = 0x08; private USARTListener listener; @@ -151,7 +151,6 @@ txbit = USART1_TX_BIT; rxVector = USART1_RX_VEC; } - reset(0); } @@ -162,7 +161,6 @@ clrBitIFG(urxifg); setBitIFG(utxifg); /* empty at start! */ utctl |= UTCTL_TXEMPTY; - // cpu.scheduleCycleEvent(txTrigger, nextTXReady); txEnabled = false; rxEnabled = false; } @@ -234,6 +232,11 @@ System.out.println(getName() + " Selected SMCLK as source"); } } + if ((data & UTCTL_URXSE) == UTCTL_URXSE) { + sfr.setAutoclear(rxVector, false); + } else { + sfr.setAutoclear(rxVector, true); + } updateBaudRate(); break; case URCTL: @@ -308,11 +311,11 @@ // When byte is read - the interruptflag is cleared! // and error status should also be cleared later... if (MSP430Constants.DEBUGGING_LEVEL > 0) { - System.out.println(getName() + " clearing rx interrupt flag " + cpu.getPC() + " byte: " + tmp); + System.out.println(getName() + " clearing rx interrupt flag " + cpu.getPC() + " byte: " + tmp); } clrBitIFG(urxifg); if (listener != null) { - listener.stateChanged(USARTListener.RXFLAG_CLEARED); + listener.stateChanged(USARTListener.RXFLAG_CLEARED); } return tmp; } @@ -407,7 +410,7 @@ if (!rxEnabled) return; if (MSP430Constants.DEBUGGING_LEVEL > 0) { - System.out.println(getName() + " byteReceived: " + b); + System.out.println(getName() + " byteReceived: " + b + " " + (char) b); } urxbuf = b & 0xff; // Indicate interrupt also! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-06 08:30:27
|
Revision: 671 http://mspsim.svn.sourceforge.net/mspsim/?rev=671&view=rev Author: joxe Date: 2010-03-06 08:30:21 +0000 (Sat, 06 Mar 2010) Log Message: ----------- removed old autoack code and fixed bug on address recognition Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-05 21:56:10 UTC (rev 670) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-06 08:30:21 UTC (rev 671) @@ -565,7 +565,7 @@ if (rxread == 2) { if (TYPE_DATA_FRAME == (memory[RAM_RXFIFO + rxPacketStart] & FRAME_TYPE)) { decodeAddress = addressDecode & (memory[RAM_RXFIFO + rxPacketStart] & ACK_REQUEST) > 0; - destinationAddressMode = (memory[RAM_RXFIFO + (rxPacketStart + 1)] >> 2) & 3; + destinationAddressMode = (memory[RAM_RXFIFO + ((rxPacketStart + 1) & 127)] >> 2) & 3; } } if (decodeAddress) { @@ -579,11 +579,6 @@ flushPacket = true; } } - System.out.print("*** Packet matched long address: " + !flushPacket + " Adr:"); - for (int i = 0; i < 8; i++) { - System.out.print(Utils.hex8(memory[RAM_RXFIFO + ((addrPos + i) & 127)]) + ":"); - } - System.out.println(" " + memory[RAM_IEEEADDR]); decodeAddress = false; } else if (destinationAddressMode == SHORT_ADDRESS && rxread == 2 + 5){ /* should check short address */ @@ -599,20 +594,13 @@ } } if (bc) flushPacket = false; - System.out.print("*** Packet matched short address: " + !flushPacket + " Adr:"); - for (int i = 0; i < 2; i++) { - System.out.print(Utils.hex8(memory[RAM_RXFIFO + ((addrPos + i) & 127)]) + ":"); - } - System.out.println(" " + memory[RAM_IEEEADDR]); decodeAddress = false; } if (flushPacket) { - System.out.println("*** Packet not for me => flush packet..."); // Immediately jump to SFD Search again... something more??? /* reset state */ rxfifoLen = rxfifoLen - rxread; rxfifoWritePos = (rxPacketStart - 1 + 128) & 127; - System.out.println("Reset to: " + rxfifoWritePos + " rxRead" + rxfifoReadPos); setSFD(false); setFIFOP(false); setFIFO(false); @@ -641,8 +629,8 @@ setFIFOP(true); setSFD(false); lastPacketStart = (rxfifoWritePos + 128 - rxlen) & 127; - if (true || DEBUG) log("RX: Complete: packetStart: " + - lastPacketStart); + if (DEBUG) log("RX: Complete: packetStart: " + + lastPacketStart + " rxPStart: " + rxPacketStart); /* if either manual ack request (shouldAck) or autoack + ACK_REQ on package do ack! */ // System.out.println("Autoack " + autoAck + " checkAutoack " + checkAutoack() + " shouldAck " + shouldAck); @@ -680,40 +668,11 @@ } } - /* TODO: refactor into two different methods on for ADDR_DECODE / ADDR_RECOG one for autoack. */ - /* Also add PAN_ID checks */ + /* any packet that has autoack request will be acked! */ private boolean checkAutoack() { /* ack request or not ? */ boolean ackReq = (memory[RAM_RXFIFO + lastPacketStart] & ACK_REQUEST) != 0; if (!ackReq) return false; - - System.out.println("Ack requested!!!"); - - /* check addressing mode */ - int destAddrMode = (memory[RAM_RXFIFO + (lastPacketStart + 1) & 127] >> 2) & 3; - if (destAddrMode == LONG_ADDRESS) { - /* here we need to check that this address is correct compared to the stored address */ - int addrSize = 8; /* this is hard coded to a long address - can be short!!! */ - int addrPos = lastPacketStart + 5; // where starts the destination address of the packet!!!?? - for (int i = 0; i < addrSize; i++) { - System.out.println("checkAutoack i " + i + " mem " + - memory[RAM_IEEEADDR + i] + " != " + memory[RAM_RXFIFO + ((addrPos + i) & 127)]); - if (memory[RAM_IEEEADDR + i] != memory[RAM_RXFIFO + ((addrPos + i) & 127)]) { - return false; - } - } - } else { - /* should check short address */ - int addrPos = lastPacketStart + 5; // where starts the destination address of the packet!!!?? - for (int i = 0; i < 2; i++) { - System.out.println("checkAutoack i " + i + " mem " + - memory[RAM_SHORTADDR + i] + " != " + memory[RAM_RXFIFO + ((addrPos + i) & 127)]); - if (memory[RAM_SHORTADDR + i] != memory[RAM_RXFIFO + ((addrPos + i) & 127)]) { - return false; - } - } - } - System.out.println("Sending Auto ACK " + memory[RAM_IEEEADDR]); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-05 21:56:16
|
Revision: 670 http://mspsim.svn.sourceforge.net/mspsim/?rev=670&view=rev Author: joxe Date: 2010-03-05 21:56:10 +0000 (Fri, 05 Mar 2010) Log Message: ----------- address decode for cc2420 - not yet fully working Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-05 17:21:13 UTC (rev 669) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-05 21:56:10 UTC (rev 670) @@ -213,6 +213,11 @@ public static final int SECURITY_ENABLED = (1<<3); public static final int ACK_REQUEST = (1<<5); public static final int INTRA_PAN = (1<<6); + + public static final int TYPE_BEACON_FRAME = 0x00; + public static final int TYPE_DATA_FRAME = 0x01; + public static final int TYPE_ACK_FRAME = 0x02; + // FCF Low public static final int DESTINATION_ADDRESS_MODE = 0x30; public static final int SOURCE_ADDRESS_MODE = 0x3; @@ -373,6 +378,7 @@ private int[] ackBuf = {0x05, 0x02, 0x00, 0x00, 0x00, 0x00}; private CCITT_CRC rxCrc = new CCITT_CRC(); private CCITT_CRC txCrc = new CCITT_CRC(); +private int rxPacketStart; public void setStateListener(StateListener listener) { stateListener = listener; @@ -506,6 +512,9 @@ return true; } + /* variables for the address recognigion */ + int destinationAddressMode = 0; + boolean decodeAddress = false; /* Receive a byte from the radio medium * @see se.sics.mspsim.chip.RFListener#receivedByte(byte) */ @@ -544,14 +553,74 @@ if(rxread == 0) { rxCrc.setCRC(0); rxlen = data & 0xff; + rxPacketStart = rxfifoWritePos; + decodeAddress = false; if (DEBUG) log("RX: Start frame length " + rxlen); // FIFO pin goes high after length byte is written to RXFIFO setFIFO(true); } else if (rxread < rxlen - 2) { /* As long as we are not in the length or FCF (CRC) we count CRC */ rxCrc.add(data & 0xff); + + if (rxread == 2) { + if (TYPE_DATA_FRAME == (memory[RAM_RXFIFO + rxPacketStart] & FRAME_TYPE)) { + decodeAddress = addressDecode & (memory[RAM_RXFIFO + rxPacketStart] & ACK_REQUEST) > 0; + destinationAddressMode = (memory[RAM_RXFIFO + (rxPacketStart + 1)] >> 2) & 3; + } + } + if (decodeAddress) { + boolean flushPacket = false; + /* here we decode the address !!! */ + if (destinationAddressMode == LONG_ADDRESS && rxread == 8 + 5) { + /* here we need to check that this address is correct compared to the stored address */ + int addrPos = rxPacketStart + 5; // where starts the destination address of the packet!!!?? + for (int i = 0; i < 8; i++) { + if (memory[RAM_IEEEADDR + i] != memory[RAM_RXFIFO + ((addrPos + i) & 127)]) { + flushPacket = true; + } + } + System.out.print("*** Packet matched long address: " + !flushPacket + " Adr:"); + for (int i = 0; i < 8; i++) { + System.out.print(Utils.hex8(memory[RAM_RXFIFO + ((addrPos + i) & 127)]) + ":"); + } + System.out.println(" " + memory[RAM_IEEEADDR]); + decodeAddress = false; + } else if (destinationAddressMode == SHORT_ADDRESS && rxread == 2 + 5){ + /* should check short address */ + int addrPos = rxPacketStart + 5; // where starts the destination address of the packet!!!?? + boolean bc = true; + for (int i = 0; i < 2; i++) { + int addrData = memory[RAM_RXFIFO + ((addrPos + i) & 127)]; + if (bc && addrData != 0xff) { + bc = false; + } + if (memory[RAM_SHORTADDR + i] != addrData) { + flushPacket = true; + } + } + if (bc) flushPacket = false; + System.out.print("*** Packet matched short address: " + !flushPacket + " Adr:"); + for (int i = 0; i < 2; i++) { + System.out.print(Utils.hex8(memory[RAM_RXFIFO + ((addrPos + i) & 127)]) + ":"); + } + System.out.println(" " + memory[RAM_IEEEADDR]); + decodeAddress = false; + } + if (flushPacket) { + System.out.println("*** Packet not for me => flush packet..."); + // Immediately jump to SFD Search again... something more??? + /* reset state */ + rxfifoLen = rxfifoLen - rxread; + rxfifoWritePos = (rxPacketStart - 1 + 128) & 127; + System.out.println("Reset to: " + rxfifoWritePos + " rxRead" + rxfifoReadPos); + setSFD(false); + setFIFOP(false); + setFIFO(false); + setState(RadioState.RX_SFD_SEARCH); + } + } } - + if(rxread++ == rxlen) { // In RX mode, FIFOP goes high, if threshold is higher than frame length.... @@ -572,7 +641,7 @@ setFIFOP(true); setSFD(false); lastPacketStart = (rxfifoWritePos + 128 - rxlen) & 127; - if (DEBUG) log("RX: Complete: packetStart: " + + if (true || DEBUG) log("RX: Complete: packetStart: " + lastPacketStart); /* if either manual ack request (shouldAck) or autoack + ACK_REQ on package do ack! */ @@ -615,18 +684,20 @@ /* Also add PAN_ID checks */ private boolean checkAutoack() { /* ack request or not ? */ - boolean ackReq = (memory[RAM_RXFIFO + lastPacketStart] & ACK_REQUEST) != 0; + boolean ackReq = (memory[RAM_RXFIFO + lastPacketStart] & ACK_REQUEST) != 0; if (!ackReq) return false; + System.out.println("Ack requested!!!"); + /* check addressing mode */ - int destAddrMode = (memory[RAM_RXFIFO + lastPacketStart + 1] >> 2) & 3; + int destAddrMode = (memory[RAM_RXFIFO + (lastPacketStart + 1) & 127] >> 2) & 3; if (destAddrMode == LONG_ADDRESS) { /* here we need to check that this address is correct compared to the stored address */ int addrSize = 8; /* this is hard coded to a long address - can be short!!! */ int addrPos = lastPacketStart + 5; // where starts the destination address of the packet!!!?? for (int i = 0; i < addrSize; i++) { - /* System.out.println("checkAutoack i " + i + " mem " + - memory[RAM_IEEEADDR + i] + " != " + memory[RAM_RXFIFO + ((addrPos + i) & 127)]);*/ + System.out.println("checkAutoack i " + i + " mem " + + memory[RAM_IEEEADDR + i] + " != " + memory[RAM_RXFIFO + ((addrPos + i) & 127)]); if (memory[RAM_IEEEADDR + i] != memory[RAM_RXFIFO + ((addrPos + i) & 127)]) { return false; } @@ -635,13 +706,14 @@ /* should check short address */ int addrPos = lastPacketStart + 5; // where starts the destination address of the packet!!!?? for (int i = 0; i < 2; i++) { - /* System.out.println("checkAutoack i " + i + " mem " + - memory[RAM_IEEEADDR + i] + " != " + memory[RAM_RXFIFO + ((addrPos + i) & 127)]);*/ + System.out.println("checkAutoack i " + i + " mem " + + memory[RAM_SHORTADDR + i] + " != " + memory[RAM_RXFIFO + ((addrPos + i) & 127)]); if (memory[RAM_SHORTADDR + i] != memory[RAM_RXFIFO + ((addrPos + i) & 127)]) { return false; } } } + System.out.println("Sending Auto ACK " + memory[RAM_IEEEADDR]); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-05 17:21:20
|
Revision: 669 http://mspsim.svn.sourceforge.net/mspsim/?rev=669&view=rev Author: joxe Date: 2010-03-05 17:21:13 +0000 (Fri, 05 Mar 2010) Log Message: ----------- fixed SFR bug causing wrong flag to be cleared after interrupt Modified Paths: -------------- mspsim/se/sics/mspsim/core/SFR.java mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/se/sics/mspsim/core/SFR.java =================================================================== --- mspsim/se/sics/mspsim/core/SFR.java 2010-03-05 15:00:43 UTC (rev 668) +++ mspsim/se/sics/mspsim/core/SFR.java 2010-03-05 17:21:13 UTC (rev 669) @@ -115,9 +115,8 @@ case ME1: case ME2: updateME(address - ME1, value); - default: - memory[address] = value; } + memory[address] = value; } // read @@ -247,7 +246,7 @@ /* clear the bits that correspond to this vector! */ int pos = irqTriggeredPos[vector]; int bit = pos & 7; - if (pos > 8) { + if (pos < 8) { ifg1 &= ~(1 << bit); } else { ifg2 &= ~(1 << bit); Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2010-03-05 15:00:43 UTC (rev 668) +++ mspsim/se/sics/mspsim/core/USART.java 2010-03-05 17:21:13 UTC (rev 669) @@ -41,6 +41,8 @@ package se.sics.mspsim.core; +import org.jfree.chart.needle.ShipNeedle; + public class USART extends IOUnit implements SFRModule { public static final boolean DEBUG = false; //true; @@ -160,7 +162,7 @@ clrBitIFG(urxifg); setBitIFG(utxifg); /* empty at start! */ utctl |= UTCTL_TXEMPTY; - cpu.scheduleCycleEvent(txTrigger, nextTXReady); + // cpu.scheduleCycleEvent(txTrigger, nextTXReady); txEnabled = false; rxEnabled = false; } @@ -352,7 +354,7 @@ // Interrupt was serviced... public void interruptServiced(int vector) { /* NOTE: this is handled by SFR : clear IFG bit if interrupt is serviced */ -// System.out.println("SFR irq"); +// System.out.println(getName() + " SFR irq " + vector + " " + txShiftReg + " " + getIFG()); } private void handleTransmit(long cycles) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-05 15:00:50
|
Revision: 668 http://mspsim.svn.sourceforge.net/mspsim/?rev=668&view=rev Author: joxe Date: 2010-03-05 15:00:43 +0000 (Fri, 05 Mar 2010) Log Message: ----------- fixed order of modules to ensure USART config is not trashed Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2010-03-05 14:34:27 UTC (rev 667) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2010-03-05 15:00:43 UTC (rev 668) @@ -224,7 +224,8 @@ } passIO = 6; - // Basic clock syst. + // SFR and Basic clock system. + ioUnits[passIO++] = sfr; ioUnits[passIO++] = bcs; // Usarts @@ -239,7 +240,6 @@ ADC12 adc12 = new ADC12(this); ioUnits[passIO++] = adc12; - ioUnits[passIO++] = sfr; for (int i = 0, n = 16; i < n; i++) { memOut[0x80 + i] = adc12; Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2010-03-05 14:34:27 UTC (rev 667) +++ mspsim/se/sics/mspsim/core/USART.java 2010-03-05 15:00:43 UTC (rev 668) @@ -176,10 +176,16 @@ } private void setBitIFG(int bits) { +// if ((bits & utxifg) > 0) { +// System.out.println(getName() + " Set utxifg"); +// } sfr.setBitIFG(uartID, bits); } private void clrBitIFG(int bits) { +// if ((bits & utxifg) > 0) { +// System.out.println(getName() + " Clear utxifg"); +// } sfr.clrBitIFG(uartID, bits); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-05 14:34:33
|
Revision: 667 http://mspsim.svn.sourceforge.net/mspsim/?rev=667&view=rev Author: joxe Date: 2010-03-05 14:34:27 +0000 (Fri, 05 Mar 2010) Log Message: ----------- changed when UTXIFG is set and cleared Modified Paths: -------------- mspsim/se/sics/mspsim/core/USART.java Modified: mspsim/se/sics/mspsim/core/USART.java =================================================================== --- mspsim/se/sics/mspsim/core/USART.java 2010-03-04 21:34:07 UTC (rev 666) +++ mspsim/se/sics/mspsim/core/USART.java 2010-03-05 14:34:27 UTC (rev 667) @@ -157,7 +157,8 @@ nextTXReady = cpu.cycles + 100; txShiftReg = nextTXByte = -1; transmitting = false; - clrBitIFG(utxifg | urxifg); + clrBitIFG(urxifg); + setBitIFG(utxifg); /* empty at start! */ utctl |= UTCTL_TXEMPTY; cpu.scheduleCycleEvent(txTrigger, nextTXReady); txEnabled = false; @@ -360,21 +361,23 @@ } /* nothing more to transmit after this - stop transmission */ if (nextTXByte == -1) { + /* TXEMPTY means both TXBUF and shiftreg empty */ utctl |= UTCTL_TXEMPTY; transmitting = false; txShiftReg = -1; } } + /* any more chars to transmit? */ if (nextTXByte != -1) { txShiftReg = nextTXByte; nextTXByte = -1; + /* txbuf always empty after this */ + setBitIFG(utxifg); transmitting = true; nextTXReady = cycles + tickPerByte + 1; - cpu.scheduleCycleEvent(txTrigger, nextTXReady); + cpu.scheduleCycleEvent(txTrigger, nextTXReady); } - /* txbuf always empty after this?! */ - setBitIFG(utxifg); if (DEBUG) { if (isIEBitsSet(utxifg)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-04 21:34:14
|
Revision: 666 http://mspsim.svn.sourceforge.net/mspsim/?rev=666&view=rev Author: joxe Date: 2010-03-04 21:34:07 +0000 (Thu, 04 Mar 2010) Log Message: ----------- removed debug printout and added some stab types handling Modified Paths: -------------- mspsim/se/sics/mspsim/debug/StabFile.java mspsim/se/sics/mspsim/debug/StabType.java mspsim/se/sics/mspsim/util/ELFDebug.java Modified: mspsim/se/sics/mspsim/debug/StabFile.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabFile.java 2010-03-03 18:28:43 UTC (rev 665) +++ mspsim/se/sics/mspsim/debug/StabFile.java 2010-03-04 21:34:07 UTC (rev 666) @@ -1,6 +1,7 @@ package se.sics.mspsim.debug; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import se.sics.mspsim.util.ELFDebug; @@ -17,12 +18,14 @@ public int stabIndex; private ArrayList<StabFunction> functions = new ArrayList<StabFunction>(); + private HashMap<String, StabType> types = new HashMap<String,StabType>(); private StabFunction lastFunction; public void handleStabs(Stab[] stabs) { int i = stabIndex; while(i < stabs.length) { ELFDebug.Stab stab = stabs[i]; + System.out.println("Handling stab: " + stab); switch(stab.type) { case ELFDebug.N_SO: if (stab.value != startAddress) { @@ -40,12 +43,23 @@ case ELFDebug.N_FUN: i += addFunction(i, stabs); break; + case ELFDebug.N_LSYM: + i += addType(i, stabs); + break; default: i++; } } } + private int addType(int i, Stab[] stabs) { + Stab stab = stabs[i]; + StabType type = new StabType(stab, types); + types.put(type.name, type); + types.put(type.internalName, type); + return 1; + } + private int addFunction(int i, Stab[] stabs) { int index = i; Stab stab = stabs[index]; Modified: mspsim/se/sics/mspsim/debug/StabType.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabType.java 2010-03-03 18:28:43 UTC (rev 665) +++ mspsim/se/sics/mspsim/debug/StabType.java 2010-03-04 21:34:07 UTC (rev 666) @@ -1,6 +1,88 @@ package se.sics.mspsim.debug; +import java.util.HashMap; + +import se.sics.mspsim.util.ELFDebug.Stab; + public class StabType { + String name; + String internalName; int size; -} + boolean signed; + StabType typeDef; + + private HashMap<String,StabType> types; + + /* typical stab that define a type */ + /* int:t(0,1)=r(0,1);-32768;32767; */ + public StabType(Stab stab, HashMap<String,StabType> types) { + this.types = types; + String typeDef = stab.data; + String[] parts = typeDef.split(":"); + name = parts[0]; + parts = parts[1].split("="); + internalName = parts[0]; + if (!handleKnown(name)) { + for (int i = 0; i < parts.length; i++) { + handleTypeDef(parts[i]); + } + } + } + + public int getSize() { + if (typeDef != null) return typeDef.getSize(); + return size; + } + + private void signed(int size) { + this.size = size; + signed = true; + } + + private void unsigned(int size) { + this.size = size; + signed = false; + } + + /* handle the known types */ + private boolean handleKnown(String name) { + if ("int".equals(name)) { + signed(2); + } else if ("unsigned int".equals(name)) { + unsigned(2); + } else if ("char".equals(name)) { + unsigned(1); + } else if ("unsigned char".equals(name)) { + unsigned(1); + } else if ("signed char".equals(name)) { + signed(1); + } else if ("long int".equals(name)) { + signed(4); + } else if ("long unsigned int".equals(name)) { + unsigned(4); + } else if ("long long int".equals(name)) { + signed(8); + } else { + return false; + } + return true; + } + + /* format: + * r(0,1);-321768;32767; (int) + * R3;8;0; + * r(0,1);4;0; (float) + * or (0,1) => same as type t(0,1) + * */ + private void handleTypeDef(String def) { + if (def.startsWith("(")) { + StabType tDef = (StabType) types.get("t" + def); + if (tDef != null) { + typeDef = tDef; + } else { + System.out.println("ERROR: can not find: " + def); + } + } + } +} \ No newline at end of file Modified: mspsim/se/sics/mspsim/util/ELFDebug.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFDebug.java 2010-03-03 18:28:43 UTC (rev 665) +++ mspsim/se/sics/mspsim/util/ELFDebug.java 2010-03-04 21:34:07 UTC (rev 666) @@ -89,7 +89,7 @@ } addr += dbgStab.entSize; } - getStabFiles(); + // getStabFiles(); } public StabFile[] getStabFiles() { @@ -299,6 +299,11 @@ this.desc = desc; this.value = value; } + + public String toString() { + return "" + Integer.toHexString(type) + " " + data + + " [" + other + "," + desc + "," + value + "]"; + } } } // ELFDebug This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-03 18:28:49
|
Revision: 665 http://mspsim.svn.sourceforge.net/mspsim/?rev=665&view=rev Author: joxe Date: 2010-03-03 18:28:43 +0000 (Wed, 03 Mar 2010) Log Message: ----------- initial debug classes for handling elf file debug info Added Paths: ----------- mspsim/se/sics/mspsim/debug/ mspsim/se/sics/mspsim/debug/StabFile.java mspsim/se/sics/mspsim/debug/StabFunction.java mspsim/se/sics/mspsim/debug/StabType.java Added: mspsim/se/sics/mspsim/debug/StabFile.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabFile.java (rev 0) +++ mspsim/se/sics/mspsim/debug/StabFile.java 2010-03-03 18:28:43 UTC (rev 665) @@ -0,0 +1,91 @@ +package se.sics.mspsim.debug; + +import java.util.ArrayList; +import java.util.Iterator; + +import se.sics.mspsim.util.ELFDebug; +import se.sics.mspsim.util.Utils; +import se.sics.mspsim.util.ELFDebug.Stab; + +public class StabFile { + + public int startAddress; + + public String path; + public String file; + + public int stabIndex; + + private ArrayList<StabFunction> functions = new ArrayList<StabFunction>(); + private StabFunction lastFunction; + + public void handleStabs(Stab[] stabs) { + int i = stabIndex; + while(i < stabs.length) { + ELFDebug.Stab stab = stabs[i]; + switch(stab.type) { + case ELFDebug.N_SO: + if (stab.value != startAddress) { + return; + } + if (stab.data.length() > 0) { + if (path == null) { + path = stab.data; + } else if (file == null) { + file = stab.data; + } + } + i++; + break; + case ELFDebug.N_FUN: + i += addFunction(i, stabs); + break; + default: + i++; + } + } + } + + private int addFunction(int i, Stab[] stabs) { + int index = i; + Stab stab = stabs[index]; + /* name:ReturnType */ + if (stab.data.length() == 0) { + /* just ens last function */ + if (lastFunction != null) { + lastFunction.endAddress = lastFunction.startAddress + stab.value; + } + return 1; + } + StabFunction fun = new StabFunction(); + functions.add(fun); + lastFunction = fun; + String[] fname = stab.data.split(":"); + fun.name = fname[0]; + fun.returnType = fname[1]; + fun.startAddress = stab.value; + fun.startLine = stab.desc; + index++; + + while (index < stabs.length && isParam(stabs[index])) { + fun.addParameter(stabs[index]); + index++; + } + + return index - i; + } + + private boolean isParam(Stab stab) { + return (stab.type == ELFDebug.N_REG_PARAM || + stab.type == ELFDebug.N_VAR_PARAM); + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("File: " + path + file + " starts at: " + startAddress + "\n"); + for (int i = 0; i < functions.size(); i++) { + sb.append(" ").append(functions.get(i)).append("\n"); + } + return sb.toString(); + } +} Added: mspsim/se/sics/mspsim/debug/StabFunction.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabFunction.java (rev 0) +++ mspsim/se/sics/mspsim/debug/StabFunction.java 2010-03-03 18:28:43 UTC (rev 665) @@ -0,0 +1,45 @@ +package se.sics.mspsim.debug; + +import java.util.ArrayList; + +import se.sics.jipv6.util.Utils; +import se.sics.mspsim.util.ELFDebug.Stab; + +public class StabFunction { + + public String name; + public String returnType; /* string representation of return type */ + public ArrayList<Param> params; + public int endAddress; + public int startAddress; + public int startLine; + + public void addParameter(Stab stab) { + if (params == null) params = new ArrayList<Param>(); + String[] name = stab.data.split(":"); + params.add(new Param(name[0])); + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("Function: " + name); + if (params != null) { + sb.append("("); + for (int i = 0; i < params.size(); i++) { + if (i > 0) sb.append(", "); + sb.append(params.get(i).name); + } + sb.append(")"); + sb.append(" at ").append(Utils.hex16(startAddress)); + sb.append(" - ").append(Utils.hex16(endAddress)); + } + return sb.toString(); + } + + class Param { + String name; + Param(String name) { + this.name = name; + } + } +} Added: mspsim/se/sics/mspsim/debug/StabType.java =================================================================== --- mspsim/se/sics/mspsim/debug/StabType.java (rev 0) +++ mspsim/se/sics/mspsim/debug/StabType.java 2010-03-03 18:28:43 UTC (rev 665) @@ -0,0 +1,6 @@ +package se.sics.mspsim.debug; + +public class StabType { + String name; + int size; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2010-03-03 18:27:24
|
Revision: 664 http://mspsim.svn.sourceforge.net/mspsim/?rev=664&view=rev Author: joxe Date: 2010-03-03 18:27:04 +0000 (Wed, 03 Mar 2010) Log Message: ----------- fixed mspsim to not jump while in LPM if an interrupt is triggered Modified Paths: -------------- mspsim/Makefile mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/util/ELF.java mspsim/se/sics/mspsim/util/ELFDebug.java Modified: mspsim/Makefile =================================================================== --- mspsim/Makefile 2010-03-02 11:57:31 UTC (rev 663) +++ mspsim/Makefile 2010-03-03 18:27:04 UTC (rev 664) @@ -71,7 +71,7 @@ SCRIPTS := ${addprefix scripts/,autorun.sc duty.sc} BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg firmware/*/*.firmware ${SCRIPTS} -PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli platform platform/esb platform/sky plugin profiler net ui util extutil/highlight extutil/jfreechart} +PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli debug platform platform/esb platform/sky plugin profiler net ui util extutil/highlight extutil/jfreechart} SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))} Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2010-03-02 11:57:31 UTC (rev 663) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2010-03-03 18:27:04 UTC (rev 664) @@ -229,7 +229,8 @@ int address = mapEntry.getAddress(); context.out.println(" " + mapEntry.getName() + " at $" + Utils.hex16(address) + " (" + Utils.hex8(cpu.memory[address]) + - " " + Utils.hex8(cpu.memory[address + 1]) + ")"); + " " + Utils.hex8(cpu.memory[address + 1]) + ") " + mapEntry.getType() + + " in file " + mapEntry.getFile()); } return 0; } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2010-03-02 11:57:31 UTC (rev 663) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2010-03-03 18:27:04 UTC (rev 664) @@ -836,10 +836,16 @@ // ------------------------------------------------------------------- // Event processing - note: This can trigger IRQs! // ------------------------------------------------------------------- + /* This can flag an interrupt! */ while (cycles >= nextEventCycles) { executeEvents(); } - + + if (interruptsEnabled && interruptMax > 0) { + /* can not allow for jumping to nextEventCycles since that would jump too far */ + return false; + } + if (maxCycles >= 0 && maxCycles < nextEventCycles) { // Should it just freeze or take on extra cycle step if cycles > max? cycles = cycles < maxCycles ? maxCycles : cycles; Modified: mspsim/se/sics/mspsim/util/ELF.java =================================================================== --- mspsim/se/sics/mspsim/util/ELF.java 2010-03-02 11:57:31 UTC (rev 663) +++ mspsim/se/sics/mspsim/util/ELF.java 2010-03-03 18:27:04 UTC (rev 664) @@ -400,7 +400,7 @@ if (file == null) { file = currentFile; } - map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, 0, symbolName, file, + map.setEntry(new MapEntry(MapEntry.TYPE.variable, sAddr, size, symbolName, file, bind == ELFSection.SYMBIND_LOCAL)); } else { if (DEBUG) { Modified: mspsim/se/sics/mspsim/util/ELFDebug.java =================================================================== --- mspsim/se/sics/mspsim/util/ELFDebug.java 2010-03-02 11:57:31 UTC (rev 663) +++ mspsim/se/sics/mspsim/util/ELFDebug.java 2010-03-03 18:27:04 UTC (rev 664) @@ -40,13 +40,20 @@ package se.sics.mspsim.util; import java.util.ArrayList; +import se.sics.mspsim.debug.StabFile; + public class ELFDebug { private Stab[] stabs; public static final int N_FUN = 0x24; + public static final int N_STSYM = 0x26; // Data segment file-scope variable; + public static final int N_LCSYM = 0x28; // BSS segment file-scope variable; + public static final int N_REG_PARAM= 0x40; + public static final int N_VAR_PARAM= 0xa0; public static final int N_SLINE = 0x44; public static final int N_SO = 0x64; // filename and path + public static final int N_LSYM = 0x80; // stack var, typdef or struct public static final boolean DEBUG = false; @@ -77,13 +84,37 @@ if (DEBUG) { System.out.println("Stab: " + Utils.hex8(type) + - " " + stabData + " o:" + other + " '" + stabData + "' o:" + other + " d:" + desc + " v:" + value); } addr += dbgStab.entSize; } + getStabFiles(); } + public StabFile[] getStabFiles() { + ArrayList files = new ArrayList(); + StabFile currentFile = null; + for (int i = 0, n = stabs.length; i < n; i++) { + Stab stab = stabs[i]; + switch(stab.type) { + case N_SO: + if (currentFile == null || currentFile.startAddress != stab.value) { + /* end of file ? */ + currentFile = new StabFile(); + files.add(currentFile); + currentFile.startAddress = stab.value; + currentFile.stabIndex = i; + currentFile.handleStabs(stabs); + System.out.println("Found: " + currentFile); + } + break; + } + } + return (StabFile[]) files.toArray(new StabFile[0]); + } + + /* Just pick up file + some other things */ public DebugInfo getDebugInfo(int address) { String currentPath = null; @@ -253,13 +284,13 @@ return sourceFilesArray; } - private static class Stab { + public static class Stab { - String data; - int type; - int other; - int desc; - int value; + public String data; + public int type; + public int other; + public int desc; + public int value; Stab(String data, int type, int other, int desc, int value) { this.data = data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2010-03-02 11:57:39
|
Revision: 663 http://mspsim.svn.sourceforge.net/mspsim/?rev=663&view=rev Author: nifi Date: 2010-03-02 11:57:31 +0000 (Tue, 02 Mar 2010) Log Message: ----------- Fixed CRC in CC2420 to be correct Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-01 22:27:08 UTC (rev 662) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2010-03-02 11:57:31 UTC (rev 663) @@ -547,12 +547,10 @@ if (DEBUG) log("RX: Start frame length " + rxlen); // FIFO pin goes high after length byte is written to RXFIFO setFIFO(true); + } else if (rxread < rxlen - 2) { + /* As long as we are not in the length or FCF (CRC) we count CRC */ + rxCrc.add(data & 0xff); } - - /* as long as we are not in the FCF (CRC) we count CRC */ - if (rxread < rxlen - 2) { - rxCrc.add(data & 0xff); - } if(rxread++ == rxlen) { // In RX mode, FIFOP goes high, if threshold is higher than frame length.... @@ -562,10 +560,8 @@ int crc = memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)] << 8; crc += memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)]; - if (crc == rxCrc.getCRC()) { - System.out.println("CRC OK"); - } else { - System.out.println("CRC not OK: recv:" + crc + " calc: " + rxCrc.getCRC()); + if (DEBUG && crc != rxCrc.getCRC()) { + log("CRC not OK: recv:" + crc + " calc: " + rxCrc.getCRC()); } // Should take a RSSI value as input or use a set-RSSI value... memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)] = (registers[REG_RSSI]) & 0xff; @@ -934,7 +930,7 @@ if (txfifoPos == 0) { txCrc.setCRC(0); int len = memory[RAM_TXFIFO] & 0xff; - for (int i = 0; i < memory[RAM_TXFIFO] - 2; i++) { + for (int i = 1; i < len - 2; i++) { txCrc.add(memory[RAM_TXFIFO + i] & 0xff); } // System.out.println("Setting TX CRC to: " + txCrc.getCRC()); @@ -975,7 +971,7 @@ if(ackPos == 0) { txCrc.setCRC(0); int len = 3; - for (int i = 0; i < len; i++) { + for (int i = 1; i < len; i++) { txCrc.add(ackBuf[i] & 0xff); } // System.out.println("Setting TX CRC to: " + txCrc.getCRC()); @@ -1273,4 +1269,4 @@ public void stateChanged(int state) { } -} // CC2420 \ No newline at end of file +} // CC2420 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |