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

Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt. Bitte hier nur auf die ursprüngliche Frage antworten, für neue Fragen einen neuen Beitrag erstellen.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.