Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
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 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.