<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Frequency counter? in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136233#M4275</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Bob,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Some further comments assuming your use of input capture facility -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If you are able to vary the prescale setting (without affecting the operation of other sections of code), you can avoid multiple timer overflows, with resultant simplification of frequency calculation.&amp;nbsp; For example, with a bus frequency of 4MHz and a prescale setting of 64, you can measure down to 1Hz without the input period exceeding the timer overflow period.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;To check for multiple timer overflows (under-range), set a flag during timer overflow ISR, and clear the flag during input capture ISR.&amp;nbsp; On entry to the timer overflow ISR, if the flag is already set, the frequency is too low, or there is no input signal.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Using this technique, you could start a measurement with maximum prescale value, and then progressively reduce the value until the period reading for a single input cycle was equal or greater than a&amp;nbsp;value of $8000.&amp;nbsp; This would achieve maximum resolution without the need to take overflow into account.&amp;nbsp; If a prescale value of 1 was reached, and the period reading was still below $8000, you could then continue to totalise the period of multiple input cycles until the criterion was reached.&amp;nbsp; For a frequency of 10kHz, this would occur after 82 cycles.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;To calculate frequency&amp;nbsp;to say 3 decimal places using integer arithmetic -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If single cycle measurement -&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;freq = fbus * 1000 /&amp;nbsp;period / prescale;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If multiple cycle measurement -&lt;BR /&gt;&lt;FONT face="Courier New"&gt;freq = fbus * cycles * 1000 / period;&amp;nbsp; // prescale = 1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 21 May 2006 11:59:48 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2006-05-21T11:59:48Z</dc:date>
    <item>
      <title>Frequency counter?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136229#M4271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Does anyone know where I might find an app note on using a 908? timer for a frequency counter?&lt;/DIV&gt;&lt;DIV&gt;Thanks, Bob&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 May 2006 06:08:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136229#M4271</guid>
      <dc:creator>BobMac</dc:creator>
      <dc:date>2006-05-17T06:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: Frequency counter?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136230#M4272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Bob,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The basic approach taken would depend on the frequency range you wish to measure, and the resolution required.&amp;nbsp; Of course, the MCU clock would need to be crystal derived for measurement accuracy.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The HC08 timer is most suited to the measurement of period, using input capture - the frequency can then be calculated.&amp;nbsp; However, this is most suited to low frequency measurements where the input period is many bus cycles.&amp;nbsp; Resolution can be increased by measuring the total period for multiple input cycles.&amp;nbsp; To further increase the measurement frequency would require external prescaler hardware.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;For direct frequency measurement of higher frequencies, you would likely need two separate timer modules (&lt;U&gt;not&lt;/U&gt; two channels in the one timer module).&amp;nbsp; One of the timers would require external clock input for connection of the signal, and the other timer would need to generate an accurate gating period of suitable duration (say one second).&amp;nbsp; The measurement of frequencies greater than the maximum bus frequency would require additional&amp;nbsp;external prescaler hardware.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;These are some of the basic considerations.&amp;nbsp; What are your actual requirements?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 May 2006 12:39:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136230#M4272</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-05-17T12:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Frequency counter?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136231#M4273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Bobmac to Bigmac HI there!&lt;/P&gt;&lt;P&gt;&amp;nbsp;I wanted to impliment a low frequency (0 to 10KHz)&amp;nbsp;freq. counter as part of a larger test equipment project. I'm not too worried about the accrecy at the moment&amp;nbsp;because our processor is crystal controlled (an AB32)&amp;nbsp;. I thought that I would bypass the "reinventing the wheel" phase of the project and learn something at the same time.&lt;/P&gt;&lt;P&gt;Thanks for your reply, Bob&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 May 2006 22:34:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136231#M4273</guid>
      <dc:creator>BobMac</dc:creator>
      <dc:date>2006-05-17T22:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Frequency counter?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136232#M4274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi There, I'm gonna mis-spell my name as Mac so I can join this party.&lt;/P&gt;&lt;P&gt;You need input capture mode to make a frequency counter in the range 0 to 10kHz. At the lower frequencies, you'll get timer overflows, which will need to be handled.&lt;/P&gt;&lt;P&gt;Donnie's engineering bulletin EB389 should be everything you can dream of. Do a keyword search for this on our site. It even has code examples.&lt;/P&gt;&lt;P&gt;good luck&lt;/P&gt;&lt;P&gt;Mac A.K.A Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 May 2006 04:46:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136232#M4274</guid>
      <dc:creator>UK_CF_FAE</dc:creator>
      <dc:date>2006-05-18T04:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Frequency counter?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136233#M4275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Bob,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Some further comments assuming your use of input capture facility -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If you are able to vary the prescale setting (without affecting the operation of other sections of code), you can avoid multiple timer overflows, with resultant simplification of frequency calculation.&amp;nbsp; For example, with a bus frequency of 4MHz and a prescale setting of 64, you can measure down to 1Hz without the input period exceeding the timer overflow period.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;To check for multiple timer overflows (under-range), set a flag during timer overflow ISR, and clear the flag during input capture ISR.&amp;nbsp; On entry to the timer overflow ISR, if the flag is already set, the frequency is too low, or there is no input signal.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Using this technique, you could start a measurement with maximum prescale value, and then progressively reduce the value until the period reading for a single input cycle was equal or greater than a&amp;nbsp;value of $8000.&amp;nbsp; This would achieve maximum resolution without the need to take overflow into account.&amp;nbsp; If a prescale value of 1 was reached, and the period reading was still below $8000, you could then continue to totalise the period of multiple input cycles until the criterion was reached.&amp;nbsp; For a frequency of 10kHz, this would occur after 82 cycles.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;To calculate frequency&amp;nbsp;to say 3 decimal places using integer arithmetic -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If single cycle measurement -&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;freq = fbus * 1000 /&amp;nbsp;period / prescale;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;If multiple cycle measurement -&lt;BR /&gt;&lt;FONT face="Courier New"&gt;freq = fbus * cycles * 1000 / period;&amp;nbsp; // prescale = 1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 May 2006 11:59:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Frequency-counter/m-p/136233#M4275</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-05-21T11:59:48Z</dc:date>
    </item>
  </channel>
</rss>

