This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

calculate the time between 2 rising edge

hi can anyone help me i need to calculate the time between 2 rising edge of square wave signal the first signal is relayed with pc10 the second with pc11

that is the schematic :

s14.postimg.org/.../counter1.png

Parents
  • Why should it work?

    You show no code that detect the leading edge.

    And you show no code actually starting the timer. Unless you start the timer on the leading edge, the length of the pulse would be (t1 - t0) where you obviously have to take into account t0 which is the timer value at the start of the pulse...

    Another thing - haven't you looked into your processors ability to start, stop or snapshort a timer when an input signal changes? That allows you to measure signas with much higher timing resolution. And you can even keep down the power consumption by not wildly busy-looping while you measure. Or spend the CPU capacity doing something else. Why not consider elegance instead of brute force?

Reply
  • Why should it work?

    You show no code that detect the leading edge.

    And you show no code actually starting the timer. Unless you start the timer on the leading edge, the length of the pulse would be (t1 - t0) where you obviously have to take into account t0 which is the timer value at the start of the pulse...

    Another thing - haven't you looked into your processors ability to start, stop or snapshort a timer when an input signal changes? That allows you to measure signas with much higher timing resolution. And you can even keep down the power consumption by not wildly busy-looping while you measure. Or spend the CPU capacity doing something else. Why not consider elegance instead of brute force?

Children