Fun with timers and interrupts on Atmel Tiny26

(Bytes)

A long time since my last post on this site... Anyway I've been experimenting a little with my Atmel Tiny26 uC today using AVR Studio 4 for development and the AVR ISP mkII programmer to program the uC.

First off I made the usual blinking LED by flipping an output pin interleaved with delaying code. That worked nicely and the next step was to use one of the two timers of the Tiny26 to create interrupts instead of actively delaying the uC. After some reading of the datasheet and some examples on the internet I got it to work and I thought I'd put the C code up here for others who might be interested in using the AVR line of uC's and programming them using the AVR-GCC compiler. I made a bunch of comments in the code about the clock prescaler and so on but I guess you should have the Tiny26 datasheet at hand if you want to closely examine what the different names are all about.

The _BV(...) macro used in the code is short for the C construct (1<<(...)) and basically just takes a pin/bit number and creates a byte with all zeros except for a one at the given pin/bit number.

This could be some very
This could be some very useful stuff, Jip, thanks for the info. It is pretty cool if you can get your micro to handle other processes while a time period is being covered, instead of having the micro wait on that one thing before processing anything else.

Thanks, jip, good to see you

Thanks, jip, good to see you back. This will be very useful, because delays etc were one of the things that tripped me up when I was experimenting with PICs, and I’m sure it’ll take some practice when I start messing with AVRs too.

Dan