I'd be nice to start a async timer with the value of 0 when I emit a signal, stop the timer when I receive the signal. The timervalue would contain the number of cycles passed until the signal was received. Is this possible with xc? I've tried to use the "global" timer value like this (code akin)
Code: Select all
emit(chanend c) {
timer t;
unsigned time;
portEmit <: 1;
t :> time;
c <: time;
}
receiver(chanend c){
timer t;
int dataIn = 0;
unsigned time, emitTime;
select {
case portReceive pinsneq(dataIn) :> dataIn
t :> time;
printf("diff: %u ", time - emitTime);
break;
case c :> emitTime:
break;
}
}
The best resolution I got was in a range of 200ns ..
Is one of this approches useful? Is there a better solution?