<?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: Capturing PWM signal in MC9S08QG8 in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155991#M8913</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;To capture a PWM signal, I assume that the frequency is constant, you must measure the pulse length of the incoming signal.&lt;/DIV&gt;&lt;DIV&gt;So set the TPMCnSC to interrupt to Capture on a rising edge. Set a RisingEdgeFlag. Enable the interrupt.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In the interrupt routine, you read the TPMCnV register and save it.&lt;/DIV&gt;&lt;DIV&gt;You change the TPMCnSC to Capture on falling edge. Clear the RisingEdge flag.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The next time you get an interrupt, read the TPMCnV register and subtract the last TPMCnV register.&lt;/DIV&gt;&lt;DIV&gt;There you have the pulse length.&lt;/DIV&gt;&lt;DIV&gt;Note that the subtraction must be a 16 bit subtraction.&lt;/DIV&gt;&lt;DIV&gt;Also the TPMMOD register should not be changed.&lt;/DIV&gt;&lt;DIV&gt;This will take automatically take care of when the the timer counter overlaps.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;At last, you must adjust the frequency to the incoming pulses. This is done by adjusting the PS2&lt;IMG alt=":smileytongue:" class="emoticon emoticon-smileytongue" id="smileytongue" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-tongue.gif" title="Smiley Tongue" /&gt;S1&lt;IMG alt=":smileytongue:" class="emoticon emoticon-smileytongue" id="smileytongue" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-tongue.gif" title="Smiley Tongue" /&gt;S0 bits in the TPMSC register.&lt;/DIV&gt;&lt;DIV&gt;Adjust it so that the longest pulse lenght does not make the 16 bit counter to wrap.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Yes, I think that is about it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Ake&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Oct 2007 16:44:20 GMT</pubDate>
    <dc:creator>Ake</dc:creator>
    <dc:date>2007-10-17T16:44:20Z</dc:date>
    <item>
      <title>Capturing PWM signal in MC9S08QG8</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155990#M8912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Dear all&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I&amp;nbsp;am working on 8 bit controller MC9S08QG8.In my application i would like to capture PWM signal from external Module( Circuit).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;So please help me out on the configuration of ports regarding this.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am having idea about capturing the PWM signal But i am unable to find how i can use my ports for capturing PWM signal&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;thank you&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards&lt;/DIV&gt;&lt;DIV&gt;Srinivas Sripada&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 16:10:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155990#M8912</guid>
      <dc:creator>sripada</dc:creator>
      <dc:date>2007-10-17T16:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing PWM signal in MC9S08QG8</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155991#M8913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;To capture a PWM signal, I assume that the frequency is constant, you must measure the pulse length of the incoming signal.&lt;/DIV&gt;&lt;DIV&gt;So set the TPMCnSC to interrupt to Capture on a rising edge. Set a RisingEdgeFlag. Enable the interrupt.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In the interrupt routine, you read the TPMCnV register and save it.&lt;/DIV&gt;&lt;DIV&gt;You change the TPMCnSC to Capture on falling edge. Clear the RisingEdge flag.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The next time you get an interrupt, read the TPMCnV register and subtract the last TPMCnV register.&lt;/DIV&gt;&lt;DIV&gt;There you have the pulse length.&lt;/DIV&gt;&lt;DIV&gt;Note that the subtraction must be a 16 bit subtraction.&lt;/DIV&gt;&lt;DIV&gt;Also the TPMMOD register should not be changed.&lt;/DIV&gt;&lt;DIV&gt;This will take automatically take care of when the the timer counter overlaps.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;At last, you must adjust the frequency to the incoming pulses. This is done by adjusting the PS2&lt;IMG alt=":smileytongue:" class="emoticon emoticon-smileytongue" id="smileytongue" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-tongue.gif" title="Smiley Tongue" /&gt;S1&lt;IMG alt=":smileytongue:" class="emoticon emoticon-smileytongue" id="smileytongue" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-tongue.gif" title="Smiley Tongue" /&gt;S0 bits in the TPMSC register.&lt;/DIV&gt;&lt;DIV&gt;Adjust it so that the longest pulse lenght does not make the 16 bit counter to wrap.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Yes, I think that is about it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Ake&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 16:44:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155991#M8913</guid>
      <dc:creator>Ake</dc:creator>
      <dc:date>2007-10-17T16:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing PWM signal in MC9S08QG8</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155992#M8914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi again,&lt;/DIV&gt;&lt;DIV&gt;If you need to capture very narrow pulses, you can use two TPM inputs and set up the TPMs to be input capture on the rising edge, and input capture on the falling edge.&lt;/DIV&gt;&lt;DIV&gt;On the falling edge interrupt, subtract the rising edge time to get tha absolute timing.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Ake&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 17:40:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155992#M8914</guid>
      <dc:creator>Ake</dc:creator>
      <dc:date>2007-10-17T17:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing PWM signal in MC9S08QG8</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155993#M8915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Make sure to set the dividers in such a way that you have the correct timing resolution AND a long enough time window to capture your narrowest and widest PWM pulses.&lt;BR /&gt;&lt;BR /&gt;I also like to zero the counter on the beginning edge and read the time on the falling edge and not have to subtract anything.&amp;nbsp; I also use the overflow flag to detect if the ending edge never happened or for longer time periods it can be used to increment and counter variable.&lt;BR /&gt;&lt;BR /&gt;Good Luck,&lt;BR /&gt;&lt;BR /&gt;Peter House&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2007 19:54:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Capturing-PWM-signal-in-MC9S08QG8/m-p/155993#M8915</guid>
      <dc:creator>PeterHouse</dc:creator>
      <dc:date>2007-10-17T19:54:30Z</dc:date>
    </item>
  </channel>
</rss>

