avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] timing things


From: Vincent Trouilliez
Subject: Re: [avr-gcc-list] timing things
Date: Tue, 18 Oct 2005 14:45:57 +0200

> hi whats the best method for timing how long thing is running for. i see 
> atmega32's have built in 8bit timers, but i'm yet to see any good 
> examples or explainations of how to use these. thing that would time how 
> long a funtion has been running for would be perfect.

Hmmm, I don't understand... what explanations do you need about the
timers exactly ? The mega32's (I use one too) datasheet offers pretty
detailed information I find, no ? Just set any timer in "normal" mode
when your function starts, and stop the timer when the function ends,
read the timer content and that's it ! You can adjust the prescaler to
define the resolution of the timing, and if your function takes long to
execute, you can use Timer1 instead of 0 and 2, are its 16bits not 8.

That said, I find it much easier and practical to just toggle a port pin
and measure the resulting pulse width with an oscilloscope. If you need
an accurate measurement, then use a freq meter in counter mode instead
of an oscilloscope. But you could as well run your program in a
simulator like gdb, and see how many cycles your function takes to
execute, that would be the most accurate answer ! I have not yet used
gdb, but sure enough you can get it to do that for you.


HTH,


--
Vince





reply via email to

[Prev in Thread] Current Thread [Next in Thread]