#include <avr/io.h> #include <avr/interrupt.h> ISR(TIMER1_COMPA_vect, ISR_BLOCK) { PORTB ^= (1 << PORTB5); // Toggle LED0 } int main(void) { // Initialization // Set LED as output DDRB |= (1 << PORTB5); // Configure PB5 as digital output PORTB &= ~(1 << PORTB5); // Set initial level for PB5 // Set up Timer/Counter1 TCCR1B |= (1 << WGM12 ); // Configure timer 1 for CTC mode OCR1A = 25000; // Set CTC compare value to 10Hz (100mS) // at 16MHz AVR clock, with a prescaler of 64 TIMSK1 |= (1 << OCIE1A ); // Enable CTC interrupt TCCR1B |= ((1 << CS10 ) | (1 << CS11 )); // Start Timer/Counter1 at F_CPU/64 // Enable all interrupts sei(); while(1); }