Hi!
Is there a simple way to measure a frequency from a TIMx_CHx pin?
I didn't find a ready-to-use function/object in Maple; did someone already implement this?
Thanks,
Frédéric
Hi!
Is there a simple way to measure a frequency from a TIMx_CHx pin?
I didn't find a ready-to-use function/object in Maple; did someone already implement this?
Thanks,
Frédéric
If you measure the period of the signal, then you should be able to inverse it to get the frequency.
If you use timers, you'll need to set the channel in input capture mode, however putting it in PWM capture mode would enable you to just read the period directly from a register. The reference manual will help you with that, this thread is also related to the topic: http://forums.leaflabs.com/topic.php?id=13460
ala42 has some code there to put the timer in input capture mode.
The other method which should work reasonably well is to use the external interrupts and capture the time using the micros() function. This should be a little bit simpler to write although the CPU will have to do the work instead of just the timer hardware.
Ok, thanks! I think that PWM input mode is the best solution.
Would be nice to have something in maple, at high level, like for PWM output mode...
You must log in to post.