<?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>Kinetis Microcontrollers中的主题 FTM Multi-channel capture of pwm input will cause code unstable?</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1266638#M60341</link>
    <description>&lt;P&gt;FTM0 channel pair 0 uses channels 0 and 1,&amp;nbsp;channel pair 1 uses channels 2 and 3, but&amp;nbsp;&amp;nbsp;capture of pwm input will cause program instability. Is the way to enable and disable interrupts incorrect?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erichsu_0-1619092967531.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142986i5E83252637732DC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erichsu_0-1619092967531.png" alt="erichsu_0-1619092967531.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;erichsu_0-1619092967531.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Apr 2021 12:03:02 GMT</pubDate>
    <dc:creator>erichsu</dc:creator>
    <dc:date>2021-04-22T12:03:02Z</dc:date>
    <item>
      <title>FTM Multi-channel capture of pwm input will cause code unstable?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1266638#M60341</link>
      <description>&lt;P&gt;FTM0 channel pair 0 uses channels 0 and 1,&amp;nbsp;channel pair 1 uses channels 2 and 3, but&amp;nbsp;&amp;nbsp;capture of pwm input will cause program instability. Is the way to enable and disable interrupts incorrect?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erichsu_0-1619092967531.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142986i5E83252637732DC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erichsu_0-1619092967531.png" alt="erichsu_0-1619092967531.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;erichsu_0-1619092967531.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 12:03:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1266638#M60341</guid>
      <dc:creator>erichsu</dc:creator>
      <dc:date>2021-04-22T12:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: FTM Multi-channel capture of pwm input will cause code unstable?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1268374#M60405</link>
      <description>&lt;P&gt;Hi Eric,&lt;/P&gt;
&lt;P&gt;Could you please let us know what is the part number you are using?&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Felipe&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 22:52:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1268374#M60405</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2021-04-26T22:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: FTM Multi-channel capture of pwm input will cause code unstable?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1269016#M60412</link>
      <description>&lt;P&gt;FRDM-KV11Z&lt;/P&gt;&lt;P&gt;pin configuration:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erichsu_0-1619538131077.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/143423iDFA68148DA197B09/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erichsu_0-1619538131077.png" alt="erichsu_0-1619538131077.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;erichsu_0-1619538131077.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 15:42:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1269016#M60412</guid>
      <dc:creator>erichsu</dc:creator>
      <dc:date>2021-04-27T15:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: FTM Multi-channel capture of pwm input will cause code unstable?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1270553#M60426</link>
      <description>&lt;P&gt;Hi Eric,&lt;/P&gt;
&lt;P&gt;Thank you for your reply. I see you are using ftm_dual_edge_capture example from the SDK as a starting point. Is there an issue if you run example code with no modifications? Could you please provide what did you modify in the example? This will help us narrow down where the issue could be.&lt;/P&gt;
&lt;P&gt;Additionally, could you please let me know what specific line of your code is the MCU halting?&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Felipe&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 21:44:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1270553#M60426</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2021-04-29T21:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: FTM Multi-channel capture of pwm input will cause code unstable?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1271106#M60438</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I see you are using ftm_dual_edge_capture example from the SDK as a starting point. Is there an issue if you run example code with no modifications?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Ans:&amp;nbsp;no problem&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you please provide what did you modify in the example?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;Ans: Modify in the exapmle&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erichsu_0-1619964913036.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/143768iC5DCE362133667F0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erichsu_0-1619964913036.png" alt="erichsu_0-1619964913036.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;erichsu_0-1619964913036.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erichsu_1-1619964946292.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/143769i3984F65D3DFC1861/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erichsu_1-1619964946292.png" alt="erichsu_1-1619964946292.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;erichsu_1-1619964946292.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;while(1)&lt;BR /&gt;{&lt;BR /&gt;// while (ftmFirstChannelInterruptFlag_PITCH != true)&lt;BR /&gt;//{&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;// while (ftmSecondChannelInterruptFlag_PITCH != true)&lt;BR /&gt;// {&lt;BR /&gt;// }&lt;BR /&gt;#if 1&lt;BR /&gt;if ((ftmFirstChannelInterruptFlag_PITCH == true) &amp;amp;&amp;amp; (ftmSecondChannelInterruptFlag_PITCH == true))&lt;BR /&gt;{&lt;BR /&gt;ftmFirstChannelInterruptFlag_PITCH = false;&lt;BR /&gt;ftmSecondChannelInterruptFlag_PITCH = false;&lt;/P&gt;&lt;P&gt;/* Clear first channel interrupt flag after the second edge is detected.*/&lt;BR /&gt;FTM_ClearStatusFlags(DEMO_FTM_BASEADDR, FTM_FIRST_CHANNEL_PITCH_FLAG);&lt;/P&gt;&lt;P&gt;/* Clear overflow interrupt flag.*/&lt;BR /&gt;FTM_ClearStatusFlags(DEMO_FTM_BASEADDR, kFTM_TimeOverflowFlag);&lt;BR /&gt;/* Disable overflow interrupt.*/&lt;BR /&gt;FTM_DisableInterrupts(DEMO_FTM_BASEADDR, kFTM_TimeOverflowInterruptEnable);&lt;/P&gt;&lt;P&gt;capture1Val_pitch = DEMO_FTM_BASEADDR-&amp;gt;CONTROLS[BOARD_FTM_INPUT_CAPTURE_CHANNEL_PAIR_PITCH * 2].CnV;&lt;BR /&gt;capture2Val_pitch = DEMO_FTM_BASEADDR-&amp;gt;CONTROLS[(BOARD_FTM_INPUT_CAPTURE_CHANNEL_PAIR_PITCH * 2) + 1].CnV;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* FTM clock source is not prescaled and is&lt;BR /&gt;* divided by 1000000 as the output is printed in microseconds&lt;BR /&gt;*/&lt;BR /&gt;if(capture2Val_pitch &amp;gt; capture1Val_pitch)&lt;BR /&gt;{&lt;BR /&gt;//PRINTF("\r\nCapture value PITCH C(n)V=%x\r\n", capture1Val_pitch);&lt;BR /&gt;//PRINTF("\r\nCapture value PITCH C(n+1)V=%x\r\n", capture2Val_pitch);&lt;BR /&gt;pulseWidth_pitch =&lt;BR /&gt;(float)(((g_secondChannelOverflowCount_PITCH - g_firstChannelOverflowCount_PITCH) * 65536 + capture2Val_pitch - capture1Val_pitch) +&lt;BR /&gt;1) /&lt;BR /&gt;((float)FTM_SOURCE_CLOCK / 1000000);&lt;BR /&gt;//PRINTF("\r\nInput signals frequency = %f hz\r\n", 1/(pulseWidth_pitch*2)*1000000);&lt;BR /&gt;PRINTF("\r\nInput signals PITCH pulse width = %f us\r\n", pulseWidth_pitch);&lt;BR /&gt;}&lt;BR /&gt;g_secondChannelOverflowCount_PITCH = 0;&lt;BR /&gt;g_firstChannelOverflowCount_PITCH = 0;&lt;/P&gt;&lt;P&gt;/* Enable first channel interrupt */&lt;BR /&gt;FTM_EnableInterrupts(DEMO_FTM_BASEADDR, FTM_FIRST_CHANNEL_INTERRUPT_ENABLE_PITCH);&lt;/P&gt;&lt;P&gt;/* Enable second channel interrupt when the second edge is detected */&lt;BR /&gt;FTM_EnableInterrupts(DEMO_FTM_BASEADDR, FTM_SECOND_CHANNEL_INTERRUPT_ENABLE_PITCH);&lt;/P&gt;&lt;P&gt;/* Enable overflow interrupt */&lt;BR /&gt;FTM_EnableInterrupts(DEMO_FTM_BASEADDR, kFTM_TimeOverflowInterruptEnable);&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;BR /&gt;if ((ftmFirstChannelInterruptFlag_YAW == true) &amp;amp;&amp;amp; (ftmSecondChannelInterruptFlag_YAW == true))&lt;BR /&gt;{&lt;BR /&gt;ftmFirstChannelInterruptFlag_YAW = false;&lt;BR /&gt;ftmSecondChannelInterruptFlag_YAW = false;&lt;/P&gt;&lt;P&gt;/* Clear first channel interrupt flag after the second edge is detected.*/&lt;BR /&gt;FTM_ClearStatusFlags(DEMO_FTM_BASEADDR, FTM_FIRST_CHANNEL_YAW_FLAG);&lt;/P&gt;&lt;P&gt;/* Clear overflow interrupt flag.*/&lt;BR /&gt;FTM_ClearStatusFlags(DEMO_FTM_BASEADDR, kFTM_TimeOverflowFlag);&lt;BR /&gt;/* Disable overflow interrupt.*/&lt;BR /&gt;FTM_DisableInterrupts(DEMO_FTM_BASEADDR, kFTM_TimeOverflowInterruptEnable);&lt;/P&gt;&lt;P&gt;capture1Val_yaw = DEMO_FTM_BASEADDR-&amp;gt;CONTROLS[BOARD_FTM_INPUT_CAPTURE_CHANNEL_PAIR_YAW * 2].CnV;&lt;BR /&gt;capture2Val_yaw = DEMO_FTM_BASEADDR-&amp;gt;CONTROLS[(BOARD_FTM_INPUT_CAPTURE_CHANNEL_PAIR_YAW * 2) + 1].CnV;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* FTM clock source is not prescaled and is&lt;BR /&gt;* divided by 1000000 as the output is printed in microseconds&lt;BR /&gt;*/&lt;BR /&gt;if(capture2Val_yaw &amp;gt; capture1Val_yaw)&lt;BR /&gt;{&lt;BR /&gt;//PRINTF("\r\nCapture value YAW C(n)V=%x\r\n", capture1Val_yaw);&lt;BR /&gt;//PRINTF("\r\nCapture value YAW C(n+1)V=%x\r\n", capture2Val_yaw);&lt;BR /&gt;pulseWidth_yaw =&lt;BR /&gt;(float)(((g_secondChannelOverflowCount_YAW - g_firstChannelOverflowCount_YAW) * 65536 + capture2Val_yaw - capture1Val_yaw) +&lt;BR /&gt;1) /&lt;BR /&gt;((float)FTM_SOURCE_CLOCK / 1000000);&lt;BR /&gt;//PRINTF("\r\nInput signals frequency = %f hz\r\n", 1/(pulseWidth_pitch*2)*1000000);&lt;BR /&gt;PRINTF("\r\nInput signals YAW pulse width = %f us\r\n", pulseWidth_yaw);&lt;BR /&gt;}&lt;BR /&gt;g_secondChannelOverflowCount_YAW = 0;&lt;BR /&gt;g_firstChannelOverflowCount_YAW = 0;&lt;/P&gt;&lt;P&gt;/* Enable first channel interrupt */&lt;BR /&gt;FTM_EnableInterrupts(DEMO_FTM_BASEADDR, FTM_FIRST_CHANNEL_INTERRUPT_ENABLE_YAW);&lt;/P&gt;&lt;P&gt;/* Enable second channel interrupt when the second edge is detected */&lt;BR /&gt;FTM_EnableInterrupts(DEMO_FTM_BASEADDR, FTM_SECOND_CHANNEL_INTERRUPT_ENABLE_YAW);&lt;/P&gt;&lt;P&gt;/* Enable overflow interrupt */&lt;BR /&gt;FTM_EnableInterrupts(DEMO_FTM_BASEADDR, kFTM_TimeOverflowInterruptEnable);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Additionally, could you please let me know what specific line of your code is the MCU halting?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;Ans: Halting&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="erichsu_2-1619965272034.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/143770i61FF81DB8A8CAD22/image-size/medium?v=v2&amp;amp;px=400" role="button" title="erichsu_2-1619965272034.png" alt="erichsu_2-1619965272034.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;erichsu_2-1619965272034.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 14:21:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1271106#M60438</guid>
      <dc:creator>erichsu</dc:creator>
      <dc:date>2021-05-02T14:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: FTM Multi-channel capture of pwm input will cause code unstable?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1275235#M60503</link>
      <description>&lt;P&gt;Hi Eric,&lt;/P&gt;
&lt;P&gt;I would recommend to try to implement this step by step, have you tried to change the example to use channel 0 and 1 before incrementing to 4 channels? If this work then it could be an issue of interrupt management, if this does not work then it could be a configuration issue.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Felipe&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 23:20:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-Multi-channel-capture-of-pwm-input-will-cause-code-unstable/m-p/1275235#M60503</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2021-05-11T23:20:11Z</dc:date>
    </item>
  </channel>
</rss>

