I am looking for some help to measure frequency on a digital input pin. I found some information online and attempted to implement it but I am not getting correct results.
The attached test code is supposed to enable the counter for a period of 10ms and then read the count accumulated. My input signal is 3V Square wave with frequency = 125 kHz. The period of the input frequency is 8us. I am expecting to accumulate a count of around 1250 but actually getting 19595.
Processor is PSOC 5LP and I am using Creator version 3.3
I have attached my little test code workspace.
Thanks in Advance
I found the issue. It was the very first read was putting erroneous count into my calculation. Now I do a dummy read first (enable, wait, disable and read counter) to ensure first actual sample is valid.
I tried ClearFIFO but I still get rubbish in first sample.