Shop OBEX P1 Docs P2 Docs Learn Events
Time difference in ms — Parallax Forums

Time difference in ms

TE44TE44 Posts: 42
edited 2007-10-01 16:19 in Propeller 1
Hello all -
············I wast to display the difference in time in (milliseconds)·between a pin going high and low
have you any suggestions ?

Thanks
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-01 15:27
    How about:
    PRI timeInMs(pin)
       waitpne(0,|<pin,0)       ' Wait for pin to be high
       startTime := cnt           ' Save starting time
       waitpeq(0,|<pin,0)       ' Wait for pin to be low
       return (cnt - startTime) / (clkfreq / 1000)
    
    


    This assumes that the pin is already set as an input and is low when the routine is executed.
    How you display the value this returns will depend on what kind of display you want to use.
  • TE44TE44 Posts: 42
    edited 2007-10-01 16:19
    gees ! Spot on (again)... Thanks again Mike..
Sign In or Register to comment.