99
Timer Interrupt
We have already seen how to use a timer as a free-running timer. However, in most cases we will need
timer interrupts. Timer interrupts are periodic interrupts which means they occur at fixed intervals
just like clock ticks. Owing to this nature we can split multiple tasks and make them appear as if all of
them are happening concurrently. For instance, we can use an ADC to measure the temperature of a
room while using a timer to periodically update the temperature display. This is the main concept in
driving segment displays, dot-matrix displays and many more although it is not the only thing we can
do with timer interrupts.
A timer interrupt is also at the heart of any typical Real-Time Operating System (RTOS).
Here we will stick to a simple example of a seven-segment display-based second counter. Rather than
demoing LED blinking with timer interrupt I chose this example because this has many applications in
the field of displaying information on LED-based displays. The same concept can be expanded for dot-
matrix displays, LED bar graphs, alphanumerical segmented displays and many more.