|
Hi Xiaowei,
In the projecxt attached, it is assumed that the input signal which is received is a square wave.
If you are trying to measure the frequency of an analog signal such as sine, triangular, sawtooth, etc, then is necessary to first convert it to a square wave.
This can be done using a comparator at the front end.
1) Care must be taken that the amplitude of the sine wave is within the Vssa and Vdda power supply of PSoC.
2) The Vmin of the sine wave should be greater than or equal to Vssa. The Vmax of the sine wave should be less than or equal to Vdda.
3) The Analog signal whose frequency is to be measured should be connected to the noninverting terminal of the comparator. The inverting input terminal should be connected to a reference voltage. It can be a VDAC which is configured to half the voltage between Vmin and Vmax of the input signal. You may also use VRef such as Vdda/2.
4) The output of the comparator should be connected to the capture input of the Counter.
The figure below shows the schematic.

|