/*
* ATtiny85 Timer0 Output COMPA mode
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#define ledPin PB0
ISR(TIMER0_COMPA_vect)
{
PORTB ^= _BV(ledPin); // toggle led
}
int main(void)
{
// setup
DDRB |= _BV(ledPin); // led pin as output
PORTB &= ~(_BV(ledPin)); // turn off LED
// timer setup, CTC mode
TCCR0A |= _BV(WGM01); // CTC mode
TCCR0B |= _BV(CS02) | _BV(CS00); // prevscaler 1024
OCR0A = 255; // set counter to max value
TIMSK |= _BV(OCIE0A); // enable CTC interrupt
sei(); // enable global interrupt
// loop
while (1);
}