Frequency measurement with TIMER1 capture unit
ATmega328P.pdf ( Register summary on p 428 )
One can measure the frequency by measuring the time period T and invert the value, f = 1/T.
TIMER1 with capture unit, simplified block diagram.
16-bit counter TIMER1 has a Capture register. At positive or negative edge (acoarding to choice) at pin ICP1/PB0, the value of TIMER1 is stored in the ICR1 register. Flag bit ICF1 indicates when this has happened.
Are you missing a signal generator? The program has been combined with the tmr0pwm.c program generating a 7812 Hz test signal that you can measure!
The full program is available here:
frequency.txt
(for Arduino use code stored as: frequency\frequency.ino)
William Sandqvist willsandqvist@gmail.com