The simplest idea:
- use a timer component to create one pulse per second (or use a global signal component to get the pulse-per-second signal)
- use a comparator to create a proper input signal from your sensor (e.g. sensor between input and ground, and a resistor between input and Vcc)
- use a counter component (UDB), configure as up-counter, capture on input, reload on capture
- connect clock to the BUS_CLK
- connect the count input to the comparator
- connect the capture input to the 1Hz timer
- connect an ISR component to the interrupt output of the counter
- on interrupt, read the capture value from the counter, multiply it by 60, finished
Any optimization (e.g. do period measurement or reciprocal frequency measurement) is left as excercise to the reader :)
@dana: counting the number of questions regarding frequency measurement in the last time, you should compile your answers together and prepare an appnote :)
@hli, basic ap note like this should come out of Cypress in my humble opinion,
and cover various ways with a counter one can do the measurements. Take into
account timing, max count rates for method chosen.
Last person to do it, was quite instructive, was Dave Van Ess on PSOC 1.
My vote is Cypress do it.
@dana: I should use larger smileys...
Surely such AppNotes should come from Cypress, especially when the question gets asked so otfen. But I just saw that you always provided so much useful information for this topic. Maybe I should compile a blog post out of this, since I already have one explaining the CPLD implementation of a reciprocal counter...