diff -Naur simulavr-1.0.0/src/hwuart.cpp simulavr-1.0.0-modified/src/hwuart.cpp
--- simulavr-1.0.0/src/hwuart.cpp	2012-02-12 16:26:38.000000000 +0100
+++ simulavr-1.0.0-modified/src/hwuart.cpp	2016-01-29 17:07:41.000000000 +0100
@@ -23,6 +23,10 @@
  *  $Id$
  */
 
+using namespace std;
+
+#include <iostream>
+#include <iomanip>
 #include "hwuart.h"
 #include "helper.h"
 
@@ -59,6 +63,8 @@
 #define UCSZ0 0x02
 #define UCPOL 0x01
 
+int traceUart = 0x00;
+
 void HWUart::SetUdr(unsigned char val) { 
     udrWrite=val;
     if ( usr&UDRE) { //the data register was empty
@@ -73,21 +79,26 @@
 void HWUart::SetUsr(unsigned char val) { 
     unsigned char usrold=usr;
 
-    if ( val & TXC) {
-        usr &=0xff-TXC; //clear TXC if 1 written to TXC
+    if (val & TXC) {
+        usr &= ~TXC; //clear TXC if 1 written to TXC
+        val &= ~TXC;
     }
 
     unsigned char irqold= ucr&usrold;
     unsigned char irqnew= ucr&usr;
 
-
     unsigned char changed=irqold^irqnew;
     unsigned char setnew= changed&irqnew;
     unsigned char clearnew= changed& (~irqnew);
 
     CheckForNewSetIrq(setnew);
     CheckForNewClearIrq(clearnew);
-} 
+
+    if (val & U2X)
+        usr |= U2X;
+    if (val & MPCM)
+        usr |= MPCM;
+}
 
 void HWUart::SetUbrr(unsigned char val) {
     ubrr = (ubrr & 0xff00) | val;
@@ -169,7 +180,10 @@
 
 unsigned int HWUart::CpuCycle() {
     baudCnt++; // TODO: this isn't implemented right, baud clock prescaler is a down counter!
-    if(baudCnt >= (ubrr + 1)) {
+
+    // quick hack: U2X should not divide the prescaler by two, rather it should
+    // double the number of states both in CpuCycleRx and CpuCycleTx
+    if(((usr&U2X)?baudCnt*2:baudCnt) >= (ubrr + 1)) {
         baudCnt = 0;
         CpuCycleRx();
         CpuCycleTx();
@@ -192,19 +206,31 @@
 
         switch (rxState) {
             case RX_WAIT_FOR_HIGH: //wait for startbit
+                if(traceUart)
+                    cout << "RX_WAIT_FOR_HIGH" << endl;
                 if (pinRx==1) rxState=RX_WAIT_FOR_LOWEDGE;
-                
+
                 break;
 
             case RX_WAIT_FOR_LOWEDGE:
-                if (pinRx==0) rxState=RX_READ_STARTBIT;
+                if(traceUart&0x02)
+                    cout << "RX_WAIT_FOR_LOWEDGE" << endl;
                 cntRxSamples=0;
                 rxLowCnt=0;
                 rxHighCnt=0;
-                break;
+                if (pinRx!=0)
+                    break;
+                rxState=RX_READ_STARTBIT;
+                if(traceUart)
+                    cout << "RX_WAIT_FOR_LOWEDGE -> RX_READ_STARTBIT" << endl;
+                // no break: this is already the first sample of the startbit
 
             case RX_READ_STARTBIT:
                 cntRxSamples++;
+                if(traceUart) {
+                    cout << "RX_READ_STARTBIT " << setw(2) << cntRxSamples;
+                    cout << "            " << pinRx << endl;
+                }
                 if (cntRxSamples>=8 && cntRxSamples<=10) {
                     if (pinRx==0) {
                         rxLowCnt++;
@@ -213,7 +239,7 @@
                     }
                 }
                 if (cntRxSamples>15) {
-                    if ( rxLowCnt>rxHighCnt) { //yes the startbit is low 
+                    if (rxLowCnt>rxHighCnt) { //yes the startbit is low 
                         cntRxSamples=0;
                         rxState= RX_READ_DATABIT;
                         rxDataTmp=0;
@@ -228,6 +254,10 @@
 
             case RX_READ_DATABIT:
                 cntRxSamples++;
+                if(traceUart) {
+                    cout << "RX_READ_DATABIT " << setw(2) << cntRxSamples;
+                    cout << "            " << pinRx << endl;
+                }
                 if (cntRxSamples>=8 && cntRxSamples<=10) {
                     if (pinRx==0) {
                         rxLowCnt++;
@@ -237,10 +267,16 @@
                 }
 
                 if (cntRxSamples>15) {
-                    if ( rxLowCnt<rxHighCnt) { //the bit was high
+                    if (rxLowCnt<rxHighCnt) { //the bit was high
+                        if(traceUart)
+                            cout << "rx: HIGH(0) " << endl;
                         rxDataTmp|=(1<<rxBitCnt);
                         readParity^=1; 
                     }
+                    else {
+                        if(traceUart)
+                            cout << "rx: LOW (1)" << endl;
+                    }
 
                     rxBitCnt++;
                     cntRxSamples=0;
@@ -261,6 +297,10 @@
 
             case RX_READ_PARITY:
                 cntRxSamples++;
+                if(traceUart) {
+                    cout << "RX_READ_PARITY" << setw(2) << cntRxSamples;
+                    cout << "            " << pinRx << endl;
+                }
                 if (cntRxSamples>=8 && cntRxSamples<=10) {
                     if (pinRx==0) {
                         rxLowCnt++;
@@ -272,7 +312,7 @@
                 if (cntRxSamples>15) {
                     bool actParity;
 
-                    if ( rxLowCnt<rxHighCnt) { //the bit was high 
+                    if (rxLowCnt<rxHighCnt) { //the bit was high 
                         actParity=1; 
                     } else {
                         actParity=0;
@@ -283,7 +323,7 @@
                     }
 
                     if (readParity==actParity) {
-                        usr&=0xff-UPE; //clear parity error
+                        usr&=~UPE; //clear parity error
                     } else {
                         usr|=UPE;
                     }
@@ -301,20 +341,27 @@
                         rxHighCnt++;
                     }
                 }
+                if(traceUart) {
+                    cout << "RX_READ_STOPBIT " << setw(2) << cntRxSamples;
+                    cout << "            " << pinRx << "           ";
+                    cout << rxLowCnt << " " << rxHighCnt << endl;
+                }
 
                 if (
-                        ((ucsrc&USBS) && (cntRxSamples>16)) || //if 2 stopbits used we have to wait full bit frame
-                        ((!(ucsrc&USBS)) && (cntRxSamples>10)) //in case of only 1 stopbit we can shorten the stopbit
+                        (cntRxSamples>15) || //if 2 stopbits used we have to wait full bit frame
+                        ((!(ucsrc&USBS)) && (cntRxSamples>10) && (pinRx==0)) //in case of only 1 stopbit we can shorten the stopbit
                    ) {
 
-                    if ( rxLowCnt<rxHighCnt) { //the bit was high this is ok
+                    if (rxLowCnt<rxHighCnt) { //the bit was high this is ok
                         udrRead=rxDataTmp&0xff;
-                        usr&=0xff-FE;
+                        if(traceUart)
+                            cout << "READ BYTE: " << udrRead << endl;
+                        usr &= ~FE;
                         if ( (ucr & CHR9) !=0 ) {
                             if ( rxDataTmp&0x100) { 
                                 ucr|=RXB8;
                             } else {
-                                ucr&=0xff-RXB8;
+                                ucr&=~RXB8;
                             }
 
                         }
@@ -325,18 +372,31 @@
                         cntRxSamples=0;
                         rxLowCnt=0;
                         rxHighCnt=0;
-                        rxState= RX_READ_STOPBIT2;  
+                        rxState= RX_READ_STOPBIT2;
                     } else {
                         if (usr&RXC) { //RXC is allready set->Overrun Error
                             usr|=OR;
                         }
                         usr|=RXC; //receiving is complete, regardless of framing error!
-                        if (rxLowCnt<rxHighCnt)
-                            rxState = RX_WAIT_FOR_LOWEDGE;
-                        else 
+                        if (rxLowCnt>=rxHighCnt)
                             rxState = RX_WAIT_FOR_HIGH;
+                        else if(pinRx==1)
+                            rxState = RX_WAIT_FOR_LOWEDGE;
+                        else {
+                            cntRxSamples=1;
+                            rxLowCnt=1;
+                            rxHighCnt=0;
+                            rxState = RX_READ_STARTBIT;
+                            if(traceUart) {
+                                cout << "RX_READ_STOPBIT -> READ_STARTBIT";
+                                cout << endl;
+                                cout << "RX_READ_STARTBIT ";
+                                cout << setw(2) << cntRxSamples;
+                                cout << "            " << pinRx << endl;
+                            }
+                        }
                     }
-                }   
+                }
                 break;
 
             case RX_READ_STOPBIT2:
@@ -348,12 +408,12 @@
                         rxHighCnt++;
                     }
                 } else if (cntRxSamples>10) { //the last stopbit could allways be shorter than normal data-bit
-                    if ( rxLowCnt<rxHighCnt) { //the bit was high this is ok
-                        usr&=0xff-FE;
+                    if (rxLowCnt<rxHighCnt) { //the bit was high this is ok
+                        usr &= ~FE;
                     } else { //stopbit was low so set framing error
                         usr|=FE;
                     }
-                    
+
                     usr|=RXC; //receiving is complete, regardless of framing error!
                     if (rxLowCnt<rxHighCnt)
                         rxState = RX_WAIT_FOR_LOWEDGE;
@@ -383,7 +443,7 @@
 }
 
 unsigned int HWUart::CpuCycleTx() {
-    /*************************************** TRANCEIVER PART **********************************/
+    /*************************************** TRANSMITTER PART **********************************/
     //unsigned char usr_old=usr;
 
     baudCnt16++;
@@ -611,9 +671,9 @@
     ubrr = 0;
     baudCnt = 0;
     baudCnt16 = 0;
-    
+
     regSeq = 0;
-    
+
     rxState = RX_WAIT_FOR_LOWEDGE;
     txState = TX_FIRST_RUN;
 
diff -Naur simulavr-1.0.0/src/measure.cpp simulavr-1.0.0-modified/src/measure.cpp
--- simulavr-1.0.0/src/measure.cpp	1970-01-01 01:00:00.000000000 +0100
+++ simulavr-1.0.0-modified/src/measure.cpp	2016-01-29 17:07:41.000000000 +0100
@@ -0,0 +1,25 @@
+/*
+ *
+ */
+
+#include <measure.h>
+#include <iostream>
+#include <iomanip>
+
+using namespace std;
+
+RWTime::RWTime(TraceValueRegister *registry, SystemClock *sc):
+    RWMemoryMember(registry, "TIME")
+{
+  clock = sc;
+}
+
+unsigned char RWTime::get() const {
+  return 0x1e;
+}
+
+void RWTime::set(unsigned char c) {
+  cout << "SystemClock (request " << setw(3) << (int) c << "): ";
+  cout << setw(10) << clock->GetCurrentTime() << endl;
+}
+
diff -Naur simulavr-1.0.0/src/measure.h simulavr-1.0.0-modified/src/measure.h
--- simulavr-1.0.0/src/measure.h	1970-01-01 01:00:00.000000000 +0100
+++ simulavr-1.0.0-modified/src/measure.h	2016-01-29 17:07:41.000000000 +0100
@@ -0,0 +1,18 @@
+/*
+ *
+ */
+
+#include<rwmem.h>
+#include<traceval.h>
+#include<systemclock.h>
+
+class RWTime : public RWMemoryMember {
+  public:
+    RWTime(TraceValueRegister *registry, SystemClock *sc);
+  protected:
+    unsigned char get() const;
+    void set(unsigned char);
+  private:
+    SystemClock *clock;
+};
+
diff -Naur simulavr-1.0.0/src/pinstop.cpp simulavr-1.0.0-modified/src/pinstop.cpp
--- simulavr-1.0.0/src/pinstop.cpp	1970-01-01 01:00:00.000000000 +0100
+++ simulavr-1.0.0-modified/src/pinstop.cpp	2016-01-29 17:07:41.000000000 +0100
@@ -0,0 +1,22 @@
+#include "pinstop.h"
+
+using namespace std;
+
+PinStop::PinStop (Pin* p, SystemClock* sc) {
+	cout << "*** pinstop created" << endl;
+	prev = Pin::TRISTATE;
+	clock = sc;
+	prev = p->GetAnalog();
+	p->RegisterCallback(this);
+	}
+       
+void PinStop::PinStateHasChanged(Pin* p) {
+	// the check is necessary since this function gets called also when the
+	// pin has not changed its output value
+	if (prev != p->GetAnalog()) {
+		cout << "*** pin state changed; time=";
+		cout << clock->Instance().GetCurrentTime() << endl;
+		prev = p->GetAnalog();
+		clock->Instance().stop();
+		}
+	}
diff -Naur simulavr-1.0.0/src/pinstop.h simulavr-1.0.0-modified/src/pinstop.h
--- simulavr-1.0.0/src/pinstop.h	1970-01-01 01:00:00.000000000 +0100
+++ simulavr-1.0.0-modified/src/pinstop.h	2016-01-29 17:07:41.000000000 +0100
@@ -0,0 +1,25 @@
+#ifndef PINSTOP
+#define PINSTOP
+
+#include "systemclock.h"
+#include "pinnotify.h"
+
+/*
+ * create an object of this class passing the AVR pin name (e.g., "D5")
+ * and a systemclock; whenever the pin changes its value the clock stops
+ *
+ * there is no need to otherwise do anything with the resulting object, the
+ * constructor already registers as a listener for the pin changes
+ */
+
+class PinStop : public HasPinNotifyFunction {
+    public:
+        PinStop(Pin* p, SystemClock* sc);
+        ~PinStop() {}
+        void PinStateHasChanged(Pin* p);
+    private:
+        SystemClock* clock;
+	int prev;
+};
+
+#endif
diff -Naur simulavr-1.0.0/src/simulavr.i simulavr-1.0.0-modified/src/simulavr.i
--- simulavr-1.0.0/src/simulavr.i	2012-02-12 16:26:38.000000000 +0100
+++ simulavr-1.0.0-modified/src/simulavr.i	2016-01-29 17:07:41.000000000 +0100
@@ -25,7 +25,9 @@
 #include "spisink.h"
 #include "adcpin.h"
 #include "pinmon.h"
+#include "pinstop.h"
 #include "rwmem.h"
+#include "measure.h"
 #include "specialmem.h"
 #include "ui/scope.h"
 #include "avrerror.h"
@@ -75,7 +77,9 @@
 %include "spisink.h"
 %include "adcpin.h"
 %include "pinmon.h"
+%include "pinstop.h"
 %include "rwmem.h"
+%include "measure.h"
 %include "specialmem.h"
 %include "ui/scope.h"
 %include "avrerror.h"
diff -Naur simulavr-1.0.0/src/ui/serialrx.cpp simulavr-1.0.0-modified/src/ui/serialrx.cpp
--- simulavr-1.0.0/src/ui/serialrx.cpp	2012-02-12 16:26:38.000000000 +0100
+++ simulavr-1.0.0-modified/src/ui/serialrx.cpp	2016-01-29 17:08:04.000000000 +0100
@@ -43,6 +43,10 @@
             SystemClock::Instance().Add(this); //as next Step() is called
         }
     }
+    else {
+        if(rxState == RX_WAIT_FOR_HIGH)
+            rxState = RX_WAIT_LOWEDGE;
+    }
 }
 
 void SerialRxBasic::Reset(){
@@ -98,11 +102,12 @@
             if (bitCnt>=maxBitCnt) {
                 // this bit IS STOP BIT... 
                 *timeToNextStepIn_ns= -1; //nothing more please
-                rxState= RX_WAIT_LOWEDGE;
+                rxState=(dataByte&0x4000) ? RX_WAIT_LOWEDGE : RX_WAIT_FOR_HIGH;
 
                 /// @todo This is bug if frame format is different (eg 7 or 9 bits)
                 unsigned char c=(unsigned char)((dataByte>>(16-maxBitCnt))&0xff); 
-                CharReceived(c);
+		if (dataByte&0x4000)
+                	CharReceived(c);
             } else {
                 *timeToNextStepIn_ns= (SystemClockOffset)1e9/baudrate/16*(7+7); //read middle of next bit
                 rxState=RX_READ_DATABIT_FIRST;
diff -Naur simulavr-1.0.0/src/ui/serialrx.h simulavr-1.0.0-modified/src/ui/serialrx.h
--- simulavr-1.0.0/src/ui/serialrx.h	2012-02-12 16:26:38.000000000 +0100
+++ simulavr-1.0.0-modified/src/ui/serialrx.h	2016-01-29 17:07:49.000000000 +0100
@@ -47,6 +47,7 @@
         int dataByte;
 
         enum T_RxState {
+            RX_WAIT_FOR_HIGH,
             RX_WAIT_LOWEDGE,
             RX_READ_STARTBIT,
             RX_READ_DATABIT_START,
diff -Naur simulavr-1.0.0/src/ui/ui.cpp simulavr-1.0.0-modified/src/ui/ui.cpp
--- simulavr-1.0.0/src/ui/ui.cpp	2012-02-12 16:26:38.000000000 +0100
+++ simulavr-1.0.0-modified/src/ui/ui.cpp	2016-01-29 17:07:41.000000000 +0100
@@ -28,6 +28,7 @@
 #include "ui.h"
 #include "hardware.h"
 #include "pin.h"
+#include "extpin.h"
 #include "systemclock.h"
 #include "avrerror.h"
 #include <sstream>
@@ -135,7 +136,7 @@
     }
     LastState[s]=c;
 
-    os << "set " << s << " " << c << endl;
+    os << "set " << s << " " << c << " " << SystemClock::Instance().GetCurrentTime() << endl;
     Write(os.str());
 
     //    SystemClock::Instance().Rescedule(this, 1000); //read ack back as fast as possible
