<?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: FRDM-MCXC242 TPM0 Timer OverFlow Capture in MCX Microcontrollers</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961221#M1684</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Regarding your question, I suppose that you do not need to set the TOIE and have the TOF fire an interrupt based on your application. You just need to enable the capture event to fire an interrupt.&lt;/P&gt;
&lt;P&gt;In the TPM0 ISR, you can read the capture value in the corresponding TPM0_CnV, then check the TOF bit, if the TOF bit is set, then you can compute the time.&lt;/P&gt;
&lt;P&gt;time=TPM0_CnV+MOD register-TPM0_CnV_Previous.&lt;/P&gt;
&lt;P&gt;then clear the TOF bit by setting the bit.&lt;/P&gt;
&lt;P&gt;If the TOF is not set,&lt;/P&gt;
&lt;P&gt;time=TPM0_CnV-TPM0_CnV_Previous.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1727231321744.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/301053i746D9C8793B93772/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1727231321744.png" alt="xiangjun_rong_0-1727231321744.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2024 02:38:20 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2024-09-25T02:38:20Z</dc:date>
    <item>
      <title>FRDM-MCXC242 TPM0 Timer OverFlow Capture</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1960810#M1681</link>
      <description>&lt;P&gt;I am not able to bring the TPM0 overflow flag set.&lt;BR /&gt;TOIE is set in register, Interrupts are active and capturing works fine.&lt;BR /&gt;&lt;BR /&gt;When I for example 2Hz I get a capture value with 62900, when I reduce the frequency to 1.8Hz I get 4100 counts and the TOF will not be set.&lt;BR /&gt;When raising the frequency everything works fine and the capture is correct.&lt;BR /&gt;&lt;BR /&gt;******************* Code initialisation ****************&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;tpm_config_t tpmInfo;&lt;/P&gt;&lt;P&gt;uint32_t helper;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;helper = SIM-&amp;gt;SCGC6; //enable TPM0 clock&lt;/P&gt;&lt;P&gt;helper |= 0x1000000;&lt;/P&gt;&lt;P&gt;SIM-&amp;gt;SCGC6 = helper;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TPM_StopTimer(TPM0_PERIPHERAL);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TPM_GetDefaultConfig(&amp;amp;tpmInfo);&lt;/P&gt;&lt;P&gt;tpmInfo.useGlobalTimeBase = false;&lt;/P&gt;&lt;P&gt;tpmInfo.prescale = kTPM_Prescale_Divide_4;&lt;/P&gt;&lt;P&gt;tpmInfo.syncGlobalTimeBase = false;&lt;/P&gt;&lt;P&gt;tpmInfo.triggerSelect = kTPM_Trigger_Select_0;&lt;/P&gt;&lt;P&gt;tpmInfo.triggerSource = kTPM_TriggerSource_External;&lt;/P&gt;&lt;P&gt;tpmInfo.extTriggerPolarity = kTPM_ExtTrigger_Active_High;&lt;/P&gt;&lt;P&gt;tpmInfo.chnlPolarity = 0U;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TPM_Init(TPM0_PERIPHERAL, &amp;amp;tpmInfo);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Setup input capture on a TPM channel */&lt;/P&gt;&lt;P&gt;TPM_SetupInputCapture(TPM0_PERIPHERAL, kTPM_Chnl_2, kTPM_RiseAndFallEdge);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Set the timer to be in free-running mode */&lt;/P&gt;&lt;P&gt;TPM_SetTimerPeriod(TPM0_PERIPHERAL, TPM_MAX_COUNTER_VALUE(TPM0_PERIPHERAL));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Enable channel interrupt&amp;nbsp; */&lt;/P&gt;&lt;P&gt;TPM_EnableInterrupts(TPM0_PERIPHERAL, kTPM_Chnl2InterruptEnable | kTPM_TimeOverflowInterruptEnable);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Enable at the NVIC */&lt;/P&gt;&lt;P&gt;EnableIRQ(TPM0_IRQn);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TPM_StartTimer(TPM0_PERIPHERAL, kTPM_SystemClock);&lt;/P&gt;&lt;P&gt;******************************************&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 24 Sep 2024 13:40:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1960810#M1681</guid>
      <dc:creator>SvenAsbach</dc:creator>
      <dc:date>2024-09-24T13:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXC242 TPM0 Timer OverFlow Capture</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961221#M1684</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Regarding your question, I suppose that you do not need to set the TOIE and have the TOF fire an interrupt based on your application. You just need to enable the capture event to fire an interrupt.&lt;/P&gt;
&lt;P&gt;In the TPM0 ISR, you can read the capture value in the corresponding TPM0_CnV, then check the TOF bit, if the TOF bit is set, then you can compute the time.&lt;/P&gt;
&lt;P&gt;time=TPM0_CnV+MOD register-TPM0_CnV_Previous.&lt;/P&gt;
&lt;P&gt;then clear the TOF bit by setting the bit.&lt;/P&gt;
&lt;P&gt;If the TOF is not set,&lt;/P&gt;
&lt;P&gt;time=TPM0_CnV-TPM0_CnV_Previous.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1727231321744.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/301053i746D9C8793B93772/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1727231321744.png" alt="xiangjun_rong_0-1727231321744.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 02:38:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961221#M1684</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2024-09-25T02:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXC242 TPM0 Timer OverFlow Capture</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961334#M1685</link>
      <description>&lt;P&gt;nice idea, but as I wrote, TOF will &lt;STRONG&gt;never&lt;/STRONG&gt; be set.&lt;BR /&gt;How should I check TOF when this flag will never be set?&lt;/P&gt;&lt;P&gt;The TOF must be checked to be sure the result is correct, an overflow result is by sure wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;SvenAsbach&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 05:31:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961334#M1685</guid>
      <dc:creator>SvenAsbach</dc:creator>
      <dc:date>2024-09-25T05:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXC242 TPM0 Timer OverFlow Capture</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961416#M1686</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;For TPM0 module, there is only one interrupt vector, so all the interrupt sources of TPM0 share the same ISR. In the ISR, you can check the TOF, if it is 1, you can write a flag. Then check if the flag is set or not.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 07:04:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961416#M1686</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2024-09-25T07:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXC242 TPM0 Timer OverFlow Capture</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961505#M1687</link>
      <description>&lt;P&gt;In the register is never written TOF to "1"!&lt;/P&gt;&lt;P&gt;As you can see in the picture, TOF is not set even when an timer overflow occurs.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SvenAsbach_0-1727251284366.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/301139i6589DA2D8E25A509/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SvenAsbach_0-1727251284366.png" alt="SvenAsbach_0-1727251284366.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 08:03:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961505#M1687</guid>
      <dc:creator>SvenAsbach</dc:creator>
      <dc:date>2024-09-25T08:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXC242 TPM0 Timer OverFlow Capture</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961775#M1694</link>
      <description>&lt;P&gt;I have changed the clocksource from MCGIRCLK to MCGPCLK and it seems to work.&lt;BR /&gt;This clock is faster then I wanted.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 12:19:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXC242-TPM0-Timer-OverFlow-Capture/m-p/1961775#M1694</guid>
      <dc:creator>SvenAsbach</dc:creator>
      <dc:date>2024-09-25T12:19:49Z</dc:date>
    </item>
  </channel>
</rss>

