AnsweredAssumed Answered

FRDM K64F low frequency pulse measurement

Question asked by es483 on Nov 27, 2017
Latest reply on Dec 5, 2017 by es483

Dear NXP community users,

I'm trying to build a project on the FRDM K64F board, in which the Micrium uC/OS-III real-time operating systems is actually running. I think that this problem, in any case, should not be too much OS dependant (correct me if I'm wrong!). I'm a student in an academic environment.
In particular I'm trying to do a low frequency pulse measurement using the Dual Capture Mode available with the Flex Timer FTM0 (so, in hardware).
The problem is the following: with the attached code, I'm able to do measurements (thanks to the FTM0 counting up to 16 bits - 65535) going as down as 5 Hz. For lower frequencies (in particular I should be able to measure at least the interval 1->5 Hz) I though I could use the same code, adding only a few lines that count how many times, while FTM0 is counting, the TOF bit is set, and so how many times I'm getting an overflow, since the interupt handler is actually called (I think) every time some events happens, indipendetly if this is due to TOF set or to dual capture mode measurement end.
Having this information, I could compute the real pulse duration (i.e. its frequency) by adding a term equal to [number of times the counter is reset=number of times TOF is set]*65536.
However, adding this kind of workaround the measurements are completely wrong, even for frequencies higher than 5 Hz (that were previuosly correctly measured).
Why is this happening? Is the board, in general, not able to handle correctly all the incoming interrupt requestes?
Since the prescaler is already set to its maximum (dividing by 128 the 60 MHz bus clock), what should I do? I have no possibility at the moment of using an external clock.

 

Thank you very much in advance.

 

The relevant pieces of code are attached to this message in a C file.

Attachments

Outcomes