Measuring freq on pin.
labsmoke
Posts: 38
Hi
I would really appreciate some guidance in the CTR/FRQ/PHS labyrinth.
i realise there are some extensive posts in this forum about these registers but nothing
really explains an easy way to measure a frequency on a pin and output it in a variable.
maybe im missing something or the answer allready exists in the manual and in this forum in some post.
if someone could post a very simple code snippet or give some guidelines i would be very happy, if theres really is such a thing as an "easy" way doing this.
i bought the prop kit a few days ago and it seems i just got a hang of the programming architeure, i think its relevant to point out that ive mastered many compilers thru the years so im not mega noob.
But its just these CTR/FRQ/PHS·registers that makes my head "spin"...ha...ha...ha...
thanks anyway.·
I would really appreciate some guidance in the CTR/FRQ/PHS labyrinth.
i realise there are some extensive posts in this forum about these registers but nothing
really explains an easy way to measure a frequency on a pin and output it in a variable.
maybe im missing something or the answer allready exists in the manual and in this forum in some post.
if someone could post a very simple code snippet or give some guidelines i would be very happy, if theres really is such a thing as an "easy" way doing this.
i bought the prop kit a few days ago and it seems i just got a hang of the programming architeure, i think its relevant to point out that ive mastered many compilers thru the years so im not mega noob.
But its just these CTR/FRQ/PHS·registers that makes my head "spin"...ha...ha...ha...
thanks anyway.·
Comments
http://www.parallax.com/dl/appnt/prop/AN001-PropellerCountersv1.1.zip
There is a fine application note AN001 from Parallax that explains everything from the ground.
With respect to your specific question:
- Clear PHSA
- Set FRQA to 1
- set CTRA to POSEDGE detection and the pin
- Wait for 1 ms
- read PHSA
Now PHSA is the exact kHz value.
For fast lower frequency detection you should measure the time of a pulse.
Edit: I again post the basic timer/counter diagram from tha data sheet because it is so immensely instructive, and I have not given up the hope that somebody will have a look at it.
The propeller without machine code gives you 10% of its performance
The propeller without machine code and timer/counters gives you 1% of its performance
Post Edited (deSilva) : 10/27/2007 12:26:59 PM GMT
You shall have thanks