AnsweredAssumed Answered

Frequency Measurement using DMA - App Note: AN5083

Question asked by David XY Zhou on Nov 21, 2016
Latest reply on Nov 28, 2016 by David XY Zhou


I have K60 Towerboard, _K60P144M150SF3RM, with MQX4.2, and CodeWarrior 10.6.4.

In your Application note AN5083 detailed the approach to measure frequency using DMA. Basically it sets a DMA channel for frequency input, uses counters(CITER, BITER) to count pulses. The frequency can be calculated with total pulses over some period of time.


But for application needs more instantaneously measurements with smaller sampling time, such as 10ms, 30ms sampling time, then there is an issue. For better accuracy, the counter values transferred by DMA on both ends for the sampling duration need to be incorporated into the calculation of the frequency for this period.


The frequency can be calculated as Freq = Pulses / Sampling Period .

But the issue is the sampling period, for high resolution of measurements, a free run timer has higher frequency (1.8Mhz), then within the sampling period AB, it may contains a number of overflows of the free run timer. To determine the number of overflows is difficult due to the race conditions between the free run time overflow (wrapping) and the DMA. (t1 ===> 0) . What is the best way to resolve it ?


Thank you,

David Zhou