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.

  • since you do not specify toolset, I will have to guess that this is a '51 question. If not ... naah in either case. get active and specify the toolset.

    If '51 use a derivative with a PCA, or, even more equipped a chip such as the SILabs F12x which has 4 timers AND a PCA.

    Erik

  • I'm sorry. I forget to specify the toolset.

    I'm using XC167CI and I have 11 diferents timers, but I have to measure so many times. I'm trying to reuse the timers but I need to measure so many things in the same moment and I don't know how I can do it because I don't have free timers.

    If someone can help me, please do it.

  • you state "measure" time
    do they start randomly, or all at the same time?
    what determines that a "time" has ended (interrupt?)
    what accuracy is needed

    Erik

  • 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.

  • 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