<?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のトピックRe: FTM for variable pulse widths</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-for-variable-pulse-widths/m-p/954669#M54858</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did. &amp;nbsp;I never got it to work. &amp;nbsp;I was able to do what I need to do with the PIT. &amp;nbsp;This can be closed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2019 21:27:13 GMT</pubDate>
    <dc:creator>JBM</dc:creator>
    <dc:date>2019-07-16T21:27:13Z</dc:date>
    <item>
      <title>FTM for variable pulse widths</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-for-variable-pulse-widths/m-p/954667#M54856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to get the FTM module to allow me to create a chain of pulses on a GPIO with varying widths -- all with 50% duty cycle and then turn the FTM module off at the end of the train of pulses. &amp;nbsp;I thought I could change the MOD and CnV values in the interrupt, but it doesn't seem to work. &amp;nbsp;Here is the FTM configuration:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt;ftm_data.data = 0xAAAA;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; ftm_data.mask = 0x8000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt;// Turn on&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; SIM_SCGC3 |= SIM_SCGC3_FTM3_MASK;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; PORTD_PCR3 = PORT_PCR_MUX(GPIO_PCR_MUX_ALT4) | PORT_PCR_DSE_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt;FTM3_MODE |= FTM_MODE_WPDIS_MASK;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; FTM3_SC = 0x0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; FTM3_CONF = 0x0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; FTM3_CNT = 0x0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; FTM3_C3SC = FTM_CnSC_MSA(0x1) | FTM_CnSC_ELSA(1) | FTM_CnSC_ELSB(0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; FTM3_MOD = FTM_PERIOD_START;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; FTM3_C3V = FTM3_MOD/2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt; FTM3_SC = FTM_SC_CLKS(0x1) | FTM_SC_PS(0x0) | FTM_SC_TOIE_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: 'courier new', courier, monospace;"&gt;enable_irq(FTM3_IRQn);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here is the interrupt:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt;void FTM3_IRQHandler(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if (FTM3_SC &amp;amp; FTM_SC_TOF_MASK)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FTM3_SC &amp;amp;= ~FTM_SC_TOF_MASK;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (ftm_data.mask)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FTM3_MOD = ftm_data.data &amp;amp; ftm_data.mask ? FTM_PERIOD_LOGICAL_ZERO : FTM_PERIOD_LOGICAL_ONE;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FTM3_C3V = FTM3_MOD/2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FTM3_PWMLOAD |= FTM_PWMLOAD_LDOK_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ftm_data.mask &amp;gt;&amp;gt;= 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FTM3_SC = 0x0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace; font-size: 12px;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The idea was to have an initial pulse period defined by FTM_PERIOD_START in the first code snippet. &amp;nbsp;Then in the interrupt set a long or short pulse depending on the data set in ftm_data.data and'd with ftm_data.mask. &amp;nbsp;The pulse widths I need are anywhere from 6 us to 40 us. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ftm_data is a global structure with two members, data and mask.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I going about this the wrong way? &amp;nbsp;What I get is 9 pulses (should be 17). &amp;nbsp;Also, the duty cycle of the first pulse varies and the successive pulses all appear have either a 0 or 100% duty cycle. &amp;nbsp;Not sure what to do at this point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using the K64 Freedom Board and KDS 3.0, if it matters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jun 2019 02:56:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-for-variable-pulse-widths/m-p/954667#M54856</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2019-06-21T02:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: FTM for variable pulse widths</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-for-variable-pulse-widths/m-p/954668#M54857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you try to update the register value in channel interrupt?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Example of the Output Compare mode when the match toggles the.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/89542iBC80F4973905FC60/image-size/large?v=v2&amp;amp;px=999" role="button" title="Example of the Output Compare mode when the match toggles the.png" alt="Example of the Output Compare mode when the match toggles the.png" /&gt;&lt;/span&gt;&lt;BR /&gt;For more detail about the register update, please refer "40.4.10 Registers updated from write buffers" of &lt;BR /&gt;K64P144M120SF5RM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2019 09:28:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-for-variable-pulse-widths/m-p/954668#M54857</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2019-06-24T09:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: FTM for variable pulse widths</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-for-variable-pulse-widths/m-p/954669#M54858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did. &amp;nbsp;I never got it to work. &amp;nbsp;I was able to do what I need to do with the PIT. &amp;nbsp;This can be closed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2019 21:27:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-for-variable-pulse-widths/m-p/954669#M54858</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2019-07-16T21:27:13Z</dc:date>
    </item>
  </channel>
</rss>

