"Often when working on microcontroller projects you need a background function to run at regular intervals. This is often done by setting up a hardware timer to generate an interrupt. The interrupt triggers an Interrupt Service Routine (ISR) to handle the periodic interrupt. In this article I describe setting up the 8-Bit Timer2 to generate interrupts on an Arduino ATMega168. I walk through steps required for setup and inside the ISR function.

If you are following the Arduino sound articles this one will be important to read as well. Future articles will make use of this timer feature to control frequency generation. In fact, I started to do this article as another installment on the sound project but decided it would be best to cover timer interrupts separately."