Measurement of time in MCU

Gast #327371
Lesenswert?

Hello

I have to perform some timing tests in the Renesas M16C. What is the
best way to calculate the time from start to end? Right now I have
created a counter, which is incremented each 1/10000 second by a timer.
However if I start another timer with an interval of 1/10 second, I get
a deviance of approx. 1/1000 second, when I read the counter at each
interrupt.

Of course I will get some uncertainty on my clock, which is okay. But
is there another (better) way of doing this? A high precision timer,
perhaps? Usage of the subclock? I could use an external timer, but I
don't think I have time to do this...

Thanks
Denker
Gast #327372
Lesenswert?

"A high precision timer, perhaps?"

all hardware timers are high precision and counting exact the crystal
clock without any error.

An error can only occur, if a bad interrupt handler was written, which
was sensitive against the interrupt response time and the delay by
other interrupts.

Typical ways for accurate timer interrupt handlers are:

- use the clear on compare or autoreload feature

- use a compare interrupt and add the desired interrupt time to the
next compare value

- use an overflow interrupt, stop the timer, add the value, where the
timer count must be shorten and start the timer again. The time, where
the timer was stopped, must also be added.



Peter

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren