Ein Beispiel:

Code:
/*Blinkende LEDs im Sekundentakt 4MHz/2^16/64=1Hz   --> 4MHz/16bit/Prescaler*/

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>

volatile char count;

SIGNAL (SIG_OVERFLOW1) {
	if (count == 1) {
		PORTB = 0xFF;
		count--;
		return;
	}
	if (count == 0) {
		PORTB = 0x00;
		count++;
		return;
	}
}

void timer (void) {

	TIMSK = _BV(TOIE1);            		//Timer Overflow Interrupt enable
	TCNT1 = 0;                			//Rücksetzen des Timers
	TCCR1B = _BV(CS11) | _BV(CS10);    //Prescaler 64
	sei ();
}

int main (void) {
	DDRB = 0xff;
	timer ();
	for (;;) {}  
}
Quelle:
http://www.mc-project.de/
Auf der Seite gibts weitere nette C-Beispiele