A few days ago I came across the source-code for this ATmega168 based Inductance Meter from Dan's Workshop Blog. Below is the code that I believe sets up an ATmega168 interrupt to measure an external frequency:
// set up the 16 bit timer as an external frequency counter: TCCR1B |= (1 << CS10)|(1 << CS11)|(1 << CS12); // External clock, rising edge TIMSK1 |= (1 << TOIE1); // Enable overflow interrupt, // it will overflow a few times in counting frequency
I'm still studying how to set ATmegas interrupts, so I don't quite understand what that code does.
My questions are:
Does the code above determine which pin will provide the frequency to be measured? How?
Would that same code define the same input interrupt pin on an ATmega328?
From the schematic posted on the site (copied below) I can see that the pin whose frequency is counted/measured is PD5 (pin 11 on the IC). Is that correct?