A number of issues involved -
1) Don't use ISR from timer to read counter, it is not a synchronous process.
2) Set timer for 2 sec, 50% duty cycle, and route compare output to the counter
enable. When gate is low, for 1 sec, read counter, then update counter
to its max value. When gate is high, for 1 sec, counter will be counting. Repeat
this cycle in code. You can use Timer compare out and route it to a pin, and set
pin to ISR on - edge (of the compare output), to indicate when to read and reload
3) There are row in routes, timer and counter routes, that have synch settings.
I have found if I want max count frequency to turn these off. But I suggest ex-
periment with these settings.
Note, when you read counter you have to subtract it from max count val,
to get counts, or Freq, example if a 16 bit counter subtract it from 65535,
eg. 2n - 1.
Additionally, if you care about absolute accuracy, use an external clock
for PSOC with target accuracy you want to achieve. That controls gate
time accuracy, hence precision. PSOC clock is accurate to only 2.5%.
Some ap notes that may be useful, attached.
Freq Counter5.zip 761.2 K
i take vc1=12;vc2=13;vc3=153; so frequency come =1006;
so, one counter period =1006,another counter period =65535;
any changes occur in aboveselecting parameters
plz attach eg.code
i dont understand an2283
plz post another example
Here is a basic project you can work from. Test F measured is 1.2 Khz, you can change
that by changing period and compare value of TestFreq16 in properties window.
Its run on a PSOCeval1, 29466.
BasicFreqCntr.Archive1.zip 1.0 MB
thank you very much dana
i want to count 1sec pulses, so tell me period value and vc1,vc2,vc3 for test frequ16
If the frequency you are measuring is 100 Hz or less you want to consider reciprocal
counting technique. If you are referring to counting pulses for 1 sec, in other words
a one second gate time, then the project settings for VC1/2/3 already take care of that.
You can use the project for measuring < 100 Hz, and measurement times will be
very long. For example if you needed to measure .001 Hertz, then min measuring gate
time would be 1000 seconds. Bigger consideration is accuracy. Thats why reciprocal
method more appropriate for very low freq signals.
So what is the freq range you are trying to measure, what measurement resolution do
you want, and what accuracy ? 3 crucial design questions to answer.
Lastly VC1/2/3 are project dependent. If the reason for these clocks is for gate only, then the
product of all the divisors must meet N = Fcpu / Fgate = VC1 x VC2 x VC3 x Gate timer divisor.
So if Fcpu = 24 Mhz, Gate = .5 Hz (1 sec gate), then N = 24000000 / .5 = 48000000. But if you
have other project needs you may choose to set VC1/2/3 to other values, and adjust total N
with Gate timer divisor.
ok tell me about reciprocal type