Timing input...
Posted: Tue Mar 12, 2019 12:41 pm
I need to record the time at which a transition occurs at an input (as accurately as possible).
My assumed code for this was
If the core is responsible for multiple things then the time recorded would, in general, be some time after the transition. Suppose, for instance, that another case in that select performed an operation that took longer than the required accuracy of the timing.
I have come across code like this on the forum.
Is this code exactly equivalent to my original code?
Or does this time the actual transition?
I have tried running it, and I have found that, the value of t returned by this process is always less than 65536, as if it is using a 1 bit timer. The timer appears to be synced by offset from the system timer.
This code returns a roughly constant difference between t1 and t0 at the 16 bit level. (it varies by one on different presses).
Final question.
Where do I find documentation on this?
Because I have only seen the notation rather than read the description, I do not know what search terms to use to get help.
My assumed code for this was
Code: Select all
timer tmr;
unsigned int t;
unsigned int v;
select
{
case p_in when pinsneq(v) :
tmr :> t;
break;
}
I have come across code like this on the forum.
Code: Select all
case p_in when pinsneq(v) :> v@ t:
break;
Or does this time the actual transition?
I have tried running it, and I have found that, the value of t returned by this process is always less than 65536, as if it is using a 1 bit timer. The timer appears to be synced by offset from the system timer.
Code: Select all
select
{
case p_button when pinsneq(button) :> button @ t0:
tmr :> t1;
printf("%x : %8x : %8x : %8x : %8x\n", button, t0, t1, t1-t0, (t1-t0)%65536);
break;
}
Final question.
Where do I find documentation on this?
Because I have only seen the notation rather than read the description, I do not know what search terms to use to get help.