How accurate does it have to be? If it can be off by a few Hz, then you could
try my method. I don't have the code on this computer, so I'll try to explain it.
Use an interupt input such as INT0 and INT1. Create a subroutine to measure
the frequency of each pin seperately and disable interupts, set the appropriate
edge type and configure a timer such as Timer 1.
First clear the interupt flag. Then, in a tight loop, poll the interupt flag until you
see it, then clear it again and start the timer. Then, in another tight loop, poll
the interupt flag until you see it. Then read the timer register and turn the
timer off. You should also add a count function in the loops that will time out
after a while and let the program continue if there is no pulse on the input. I'll
post an example when I get a chance.
Keep commands in the measuring loop to a minimum to reduce the latency. This
still may not be fast enough for the frequencies that you are talking about,
but it seems to work pretty good at lower frequencies.
Bookmarks