Log in

View Full Version : Timers


MarkVH
13-02-2005, 10:39
How do you use timers and what is the smallest amount of time that they can measure?

Alan Anderson
13-02-2005, 11:30
How do you use timers and what is the smallest amount of time that they can measure?
There are three different ways I can think of immediately to use timers. The appropriate answer depends on what you want to use them for.

If you want to make something happen at a specific time, and especially if you want to make something repeat every so often, you probably should consider using timer interrupts.

If you want to find out how long something takes, you can just read the value of the timer at the beginning and the end of the interval and subtract the values. If the time might be longer than the timer can deal with, you should account for overflows, which can be done either by watching the timer constantly or by using timer interrutps.

You can also reset the timer to zero at the beginning of the interval, and read the time directly at the end (again accounting for overflows if necessary).

I think the maximum rate the timers can run at is 40 MHz.