#ifndef F_CPU #define F_CPU 20000000UL // 20 MHz clock speed #endif #include #include ISR(TIMER1_CAPT_vect) { PORTC ^= 0xFF; } int main(void) { // Initialize Periphery // quick and dirty debug LED DDRC = 0xFF; // pin D6 (ICP) is digital input with pullup DDRD &= ~(1 << PD6); PORTD |= (1 << PD6); // Initialize Timer1 // prescaler: 64 TCCR1B = (1 << CS11) | (1 << CS10) \ // input capture on rising edge | (1 << ICES1); // mode: normal // TCCR1A unchanged // enable input capture interrupt TIMSK1 = (1 << ICIE1); // global interrupt enable sei(); while(1) { // loop } }