This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to get time interval?

Other Parts Discussed in Thread: LM3S8962, ENERGIA

Hello, I am using lm3s8962 mcu and stellarisware6594 as library.

I have been struggling to code to work hc-sr04 sensor to get distance. 

I would like to know how to calculate elapsed time between two points.

For example, when I output GPIO pulse high, and by the time that GPIO pulse changes low.  I want to know how long high pulse elapses.

I thought of getting the clock numbers at the two points and subtract them. Because I know how long a clock takes (since using 8mhz clocks)

 I thought of using SysTickValueGet() but I couldn't use it. 

Can anyone help me out? I would really appreciate your help.

Dognseop

  •  for the TM4C123 or the old LM4F stellaris board i use either the RTC or the systick

    look here in how to use the Systick http://forum.stellarisiti.com/topic/2043-change-millis-micros-to-use-systick-on-tiva-based-boards/

    or here the RTC http://forum.stellarisiti.com/topic/2005-tm4c129-hibernation-rtc-and-calendar-mode/?p=7350

    sorry, i missed the part about the hc-sr04 and only read you wanted to count time

  • Hi,

    @Dongseop, one preferred method is to use a timer in timer capture mode, and set it to capture both edges. At each interrupt (edge) read the timer and then make the difference, taking into account also the number of overtimes - 

    The data sheet specify to be prepared for a time range of ~60 ms, so take into account on Stellaris you should use the timer in timer split configurations. You may start by configuring/enabling interrupts on leading edge, then if the interrupts  comes, to change to falling edge the next interrupt. Overtime interrupt should be enabled also. After the falling edge make the calculations and configure for leading edge.

    @Louis, your method does not apply here, neither the user does specify expressly the Energia use. BTW, are you LRA on that forum?

    Petrei

  • My method is not specific for Energia it only uses TivaWare functions. Why, yes i am L.R.A

    And yes i'm sorry, i only read time intervals @dongseop SHIN disegard my first post i thougt you wanted to count time

    For SRF04 i use this (it's not Energia dependant) http://forum.stellarisiti.com/topic/2004-pulse-legth-measure-srf04-example/