Hi guys
First of all I would like to say thank you for providing this excellent community for sharing information and knowledge! Really appreciate it!
I have been working with electronics for many years purely as a hobby, and started on embedded programming a few years back. With that in mind, please be patient with we if I don't quite understand things right off the bat.
Anyway. I was hoping that someone could help me out with this little project of mine:
I am trying to make a code for measuring the frequency of an incomming square wave signal with an ATmega88P MCU. I have already read the application note from Atmel (AVR205) on the subject, but got quite lost very quickly in there! Is it really that complicated??
As I understand, there are different approaches on how to measure frequency; the route I have choosen revolves around the use of the input capture pin as input for the signal I want to measure, and setting up T/C1 as a counting module.
I have thus far managed to set up T/C1 correctly, and I have programmed the fuses to run the MCU at 16MHz. No problem.
I have even been able to set up interrupts, so I can measure the number of pin change events on ICP1. But I can't seem to get my head around how to count the input events during a certain time interval? I'm able to display overflows, TCNT1 and ICR1 values on my LCD, so that works a treat;)
I would in essence like to be able to count the number of input events during, say, 1000ms or so, and then extrapolate the frequency from that.
I know that this is possible but I have not been able to understand how to write the code for doing so. I read about DFM (Direct Frequency Measurement) and RFM (Reverse Frequency Measurement), and that I need to have a TOC (Timebase Oscillator Circuit), T/C1, to generate a steady timing interval for measurement, but that's all she wrote...!
I hope this made sense, and await in anxeity your answers;)
Best regards,
X.el_ION