You are here

Frequency measurement using PSoC1 | Cypress Semiconductor

Frequency measurement using PSoC1

Summary: 5 Replies, Latest post by danaaknight on 20 Mar 2015 02:10 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
hchawla94's picture
1 post

 Can someone tell how do I measure frequency of a incoming sine wave using PSoC 1. I'm following the given procedure given by Dana.

At the most basic level you need a gate of known width in time, 

and a counter that starts counting when gate is active (high), 
from a known value (255 8 bit,  65535 16 bit), and stops counting
when gate goes low. You read the value of the counter, subtract 
it from start value, and divide by gate period in seconds.

16 bit example, .1 sec gate period, f = (65535 – count value) / .1

To setup Gate

1) Timer, setup for .1 or 1 sec (resolution would be 10 Hz or 1 Hz
respectively). You set up period to be 2X desired gate period, and
compare value 1/2 period, so that high time of compare output =
gate period, low time = gate period.

2) Route timer compare out to counter enable.

To setup counter

1) Route pin, Fin, to counter clock

2) Route timer compare out to counter enable


1) Load counter with its max allowed value, 255 for 8 bit, 65535 for
16 bit

2) Start counter

3) Enable timer ISR, on terminal count, that means gate is low, counter
not enabled to count

3) Start timer

When ISR occurs set a flag and return

1) If flag true read counter (gate is low so it is not enabling counter)
and compute frequency. Reload counter with its max value.

There are other optimizations that can be done, for example stop and reset
timer when ISR occurs so that gate low period is minimized, and measurement
frequency is increased.

If the frequencies you are measuring are very low, like less than 1 Hz,
use reciprocal counter technique.



But I'm unable to comprehend that how do I write the ISR on terminal count.

Any help would be appreciated


user_1377889's picture
9307 posts

When you type "frequency measure PSoC1" into the "Keyword Search" field at top of this page, yofind at least this appnote.



user_14586677's picture
7646 posts

Here is a couple of approaches you can use for freq measurement ,



Regards, Dana.

user_14586677's picture
7646 posts

The other approach, attached.


Regards, Dana.

user_14586677's picture
7646 posts

Sorry, not paying attention to the fact you are working with PSOC 1.


Here, attached, is a PSOC 1 solution.


Regards, Dana.

user_14586677's picture
7646 posts

This might be useful to you -



Regards, Dana.

Log in to post new comments.