Timer Basics: How Timers Work
Frequency, Time-Period, Resolution
The Timer’s ability to create a consistent, periodic interrupt is quite valuable to system designers.
Frequency and Time Period are two terms that are often used to describe the rate of interrupts.
• How many times per second that a timer creates an interrupt defines its Frequency.
• Conversely, the amount of time in-between interrupt events is defined as the Time Period.
Frequency, Time Period, Resolution
timer interrupt
timer interrupt
timer interrupt
Time Period
Definitions
Frequency: How many times per second
Time Period: Amount of time between successive events
Resolution: Granularity in determining system events
With what resolution can
we determine if an
event occurred here?
If a timer only consisted of a single counter, its resolution would be limited to the size of the
counter.
If some event were to happen in a system – say, a user pushed a button – we could only
ascertain if that event occurred within a time period. In other words, we can only determine if it
happened between two interrupts.
Looking at the above diagram, we can see that there is “more data” available – that is, if we were
to read the actual counter value when the event occurred. Actually, we can do this by setting up a
GPIO interrupt; then, having the ISR read the value from the counter register. In this case the
resolution would be better, but it is still limited by:
• It takes more hardware (an extra GPIO pin is needed)
• The CPU has to execute code – this consumes power and processing cycles
• The resolution is less deterministic because it’s based upon the latency of the interrupt
response; in other words, how fast can the CPU get to reading the counter … and how
consistent can this be each time it occurs
There is a better way to implement this in your system … turn the page and let’s examine the
timer’s Capture feature.
MSP430 Workshop - Timers 6 - 7