In the code sequence above the code does simply execute sequentially. So the second pulse will not be processed until after the first one has been processed. This is a problem because it takes longer to execute the instructions between the inputs than the difference in time between the edges.JohnR wrote:It is almost as if the system was not processing the second pulse until the first pulse had been processed??Code: Select all
if(peek(start)==0) // only wait for start with input low { start when pinseq(1) :> void; // @ tStart; tmr :> tStart; test <: 1; stop when pinseq(1) :> void; // @ tStop; tmr :> tStop; test <: 0; tmr :> t; delay = delay + (tStop - tStart);
One way around this is to setup two threads both performing a timestamped input on one of the two ports that we want to time. When the second thread detects the edge, it can report the time down a channel to the first thread which can then compute the delay between the two.