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

Reuse timers

I have to measure some many time periods so I need to reuse timers.

Can someone help me?

Thanks.

Parents
  • Hello, Erik!

    I have so many inputs and so many outs. I have to measure how long time the different signal are set. Another thing that I have to measure it is the time between two inputs. Whatever input could be set in whatever moment, so this is one of my problems (I can't use whatever timer I have to reserve some timer to do another things)

    I don't know if my explication is good.

    Thanks.

Reply
  • Hello, Erik!

    I have so many inputs and so many outs. I have to measure how long time the different signal are set. Another thing that I have to measure it is the time between two inputs. Whatever input could be set in whatever moment, so this is one of my problems (I can't use whatever timer I have to reserve some timer to do another things)

    I don't know if my explication is good.

    Thanks.

Children
  • since you do not specify precision/resolution here is one way.

    Run T2 as a free running timer and in the interrupt increment the variable Ralph. Depending on how long your program must run between resets Ralph can be char, short or long. When the state of an even input changes to on use RCAP2 to read the timer, briefly disable T2 interrupt and read Ralph. When the event end, do the same.
    The difference between the two will be the time.

    no guarantee, this is an unqualified estimate: this would give you a max error of about 200 clocks.
    I can see no better precison using one timer with that many inputs. If you need better precision you will need to gang timers/5 uCs with PCA.

    Erik