Hello, I have wired up a frequency meter using 89C4051.The signal is connected to P3.4/T0 pin.The circuit runs on 24MHz crystal.Can anyone give me the code of a frequency counter?Thanks in advance...
per listed out a fairly good approach to code this.
in general:
1) you will need to put a timer into its counter mode. in its isr, you will need to increment a variable to create a software multi-byte counter. for example, in this case, your TH1:TL1 form a 16-bit counter and freq:TH1:TL1 form a 32 bit counter if freq is a 16-bit type.
your frequency count is essentially freq:TH1:TL1 at end of the counting interval
2) you will need to put another timer into its timer mode. this timer will stop the counter mentioned above. depending on the frequency you are counting, you can use isr or no isr for this timer. and how long you set the interval to depends on the frequency you are counting.
that's pretty much all you need for this task. it is a very simple coding job.