A possibile scheme for an interrupt-driven software timer

Submitted by Ed_B on Sat, 05/15/2010 - 17:26

Printer-friendly versionPrinter-friendly version

All the discussion about interrupts in the AVR and Arduino got me to thinking about how to set up a small handfull of software timers that could do fairly accurate, low-speed timing of function calls. As long as the function calls were brief, you should be able to schedule their activataion on a timed basis. Flowcharts to the rescue! Here's a plan for one channel of a multi-channel interrupt-driven timer I'd like to flesh out and try in an AVR. (read more)

There are several ways to hook scheduled function calls into an MCU timer.  Taking the ATMega168 as a starting point, and looking at the ways the Arduino uses the three timers in the chip, it's pretty obvious that timers that do arbitrary kinds of things would have to be the software kind.

Long ago, I used to play around with TTL and CMOS logic chips. Programmable sequencers and timers were a pretty big deal, and I built lots of them. The general scheme was to use a set of thumbwheel  switches to hold the desired count, a string of BCD counters like CD4510's to do the work, and 74HC688 8-bit magnitude comparators to fire upon a match between the counter and the switch settings. To watch the count run, there would be a numerical LED display tapped into the counter through LED driver chips. Input, control, reset, and output from the timer/counter was part of the surrounding logic circuitry that formed the rest of the device. And that's how I still think of timer/counters. We'll have to see what the AVR thinks.