AnsweredAssumed Answered

Fast frequency meter, hints and limitations

Question asked by Catosh on Mar 2, 2015
Latest reply on Mar 4, 2015 by jeremyzhou

Hello,

I have a couple of questions about frequency measurement in Kinetis MCUs (K22).

First of all, I would like to measure some fast signal (a clock) with a frequency of 1/10th of core clock( let's say 48MHz of core clock, 5 mhz max of input frequency). According to the datasheet, my max input frequency shall be core clock /4
Is there a way to calculate what will my accuracy be? Ok, I suppose it will depend from the "architecture" I am going to use to perform measurements. And so, here comes the first "true" question.

What's the best approach to measure a fast signal like this one?

Three possibile approaches:

  1. Using FTM on CHn as input capture and store X values (let's say 64) of FTM_CnV. Then I will average the mean tick between the edges of the signal and computate the input frequency. Obviously, this is pretty un-accurate: +- 1 clock cycle on a 48MHZ FTM0 means that the measured frequency will vary from 5.33MHz to 4.79Hz. Not very good for my sake.
  2. Using FTM on CHn and count the number of edges in a bigger period. For example, FTM0 as input capture, FTM1 as reference. When a TOF IRQ is triggered on FTM1 I can estimate the frequency doing a simple divison:  Freq = (NumberOfEdges / MeasurementTime).
    1. Anyway, for a fast clock measurement in my sysyem this method seems to have a serious problem: nested IRQs. So I switched to FTM1 to FTM0 and check for the asserted flag into IRQ.
  3. Using FTM0 as an external clocked timer, set as upcounter and FTM1 as reference for a bigger period. BUT I can set up prescalers on FTM0 in order to slowdown the clock and prevent the nested IRQs trouble. This is very similar to method 2.

 

I already saw a couple of other threads like How can I measure frequency (0 - 100KHz) of a signal using a K10 microcontroller? but I couldn't figure out the "best practice" for this kind of measurement.

 

Any hint would be gladly appreciated.

Best regards,

 

Luca.

Outcomes