lpcware

Frequency detection

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by akshimmu on Tue Jun 16 22:05:33 MST 2015
I have to read 5 different frequencies(square wave) by polling 5 different pins.
Im using a single timer interrupt only,for every 1 millisecond.
Polling of the pins would be done in the ISR.

The algorithm i have thought of so far is:
1.Count number of HIGH
2.Count number of LOW
3.Check if sum of HIGH+LOW=Time period.
This algorithm seems slow and is not practical.

Is there any Filter functions that i could use to check the frequency at pin so that all i have to do would be to call that function?
Any other algorithms also for frequency detection would be good.

I am restricted to only 1 interrupt in my code(timer interrupt)

Outcomes