<?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 FTM generate pulse, Unable to modify CnV register in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349295#M17124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm on a K60 and test to generate pulse to drive stepper motor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a working code which can generate a pulse of a determined wide and period. (CNTIN; MOD&amp;nbsp; / CnV; C(n+1)V)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then with the following code I generate a square signal (CNTIN = 0, MOD = 65535, Cnv = 1, Cn+1V = 0x8000)&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14273010456278226" jivemacro_uid="_14273010456278226"&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; SIM&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;SCGC6 &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; SIM_SCGC6_FTM0_MASK; 
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;MODE &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_MODE_WPDIS_MASK &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_MODE_INIT_MASK ;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Set up mode register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;MODE &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_MODE_FTMEN_MASK;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* FTMEN bit is write protected. Can be written only when WPDIS = 1 */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;SC &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x00&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;UL;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Clear status and control register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CNTIN&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x00&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;UL;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Clear counter initial register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;MOD &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)(DV_PWM_MODULO&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;);&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Set up modulo register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CNT &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x00&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;UL;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Reset counter register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnSC &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_CnSC_ELSB_MASK;&amp;nbsp; 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnSC &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_CnSC_CHIE_MASK;&amp;nbsp; 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;COMBINE &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_COMBINE_COMBINE0_MASK;&amp;nbsp; 
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnV&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Allow to modify pulse start */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnV &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x8000&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Allow to modify Pulse end */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; 
 
 PORTC&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;PCR[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;STRONG&gt;PORT_PCR_MUX&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;4&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;);
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;SC&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)(&lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* //debug AG FTM_SC_TOIE_MASK |*/&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;STRONG&gt;FTM_SC_CLKS&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;STRONG&gt;FTM_SC_PS&lt;/STRONG&gt;(DV_PWM_PRESCALER));&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Set up status and control register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 &lt;/SPAN&gt;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To test some possibility, I just configure the CHn+1IE and Flag to generate the interrupt on Falling edge (Cn+1V = FTM Counter)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14273010455598780" jivemacro_uid="_14273010455598780"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;STRONG&gt;__attribute__ &lt;/STRONG&gt;((&lt;/SPAN&gt;&lt;SPAN style="; color: #000080; font-size: 10pt;"&gt;&lt;STRONG&gt;interrupt&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)) &lt;STRONG&gt;DV_Pwm_FTM0IRQ&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="; color: #000080; font-size: 10pt;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)
 &lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-size: 10pt;"&gt;{&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Toggle port debug */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 PTC&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;PTOR &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x00000001&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;
 
 &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Increment Cn+1V */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnV&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;++&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnSC &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;&amp;amp;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;~&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;FTM_CnSC_CHF_MASK; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;// clear flag
 &lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-size: 10pt;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 &lt;/SPAN&gt;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But after test, IT occurs because My debug Pin on PTC0&amp;nbsp; toggle.&lt;/P&gt;&lt;P&gt;But the Cn+1V which is incremented on the Interrupt has no effect on my output signal which should pass from a initial duty cycle of 50% to 100% and then 0%&amp;nbsp; to 100% etc...&lt;/P&gt;&lt;P&gt;But signal still 50% duty!.&lt;/P&gt;&lt;P&gt;SYNCEN is set to 0,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so I don't see why Cn+1V is not impacted?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I read the RM, But I think the Update register should be OK because SYNCEN = 0 &amp;amp; SYNCMODE = 0):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Screen1.jpg"&gt;&lt;IMG alt="Screen1.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/49525iED7A695D72DE10C2/image-size/large?v=v2&amp;amp;px=999" title="Screen1.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Screen2.jpg"&gt;&lt;IMG alt="Screen2.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/49564i2CCFEC295A09311B/image-size/large?v=v2&amp;amp;px=999" title="Screen2.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 13:12:09 GMT</pubDate>
    <dc:creator>arnogir</dc:creator>
    <dc:date>2020-11-02T13:12:09Z</dc:date>
    <item>
      <title>FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349295#M17124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm on a K60 and test to generate pulse to drive stepper motor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a working code which can generate a pulse of a determined wide and period. (CNTIN; MOD&amp;nbsp; / CnV; C(n+1)V)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then with the following code I generate a square signal (CNTIN = 0, MOD = 65535, Cnv = 1, Cn+1V = 0x8000)&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14273010456278226" jivemacro_uid="_14273010456278226"&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; SIM&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;SCGC6 &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; SIM_SCGC6_FTM0_MASK; 
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;MODE &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_MODE_WPDIS_MASK &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_MODE_INIT_MASK ;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Set up mode register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;MODE &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_MODE_FTMEN_MASK;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* FTMEN bit is write protected. Can be written only when WPDIS = 1 */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;SC &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x00&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;UL;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Clear status and control register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CNTIN&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x00&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;UL;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Clear counter initial register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;MOD &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)(DV_PWM_MODULO&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;);&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Set up modulo register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CNT &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x00&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;UL;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Reset counter register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnSC &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_CnSC_ELSB_MASK;&amp;nbsp; 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnSC &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_CnSC_CHIE_MASK;&amp;nbsp; 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;COMBINE &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_COMBINE_COMBINE0_MASK;&amp;nbsp; 
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnV&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Allow to modify pulse start */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnV &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x8000&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Allow to modify Pulse end */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; 
 
 PORTC&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;PCR[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;STRONG&gt;PORT_PCR_MUX&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;4&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;);
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;SC&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (uint32_t)(&lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* //debug AG FTM_SC_TOIE_MASK |*/&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;STRONG&gt;FTM_SC_CLKS&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;STRONG&gt;FTM_SC_PS&lt;/STRONG&gt;(DV_PWM_PRESCALER));&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Set up status and control register */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 &lt;/SPAN&gt;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To test some possibility, I just configure the CHn+1IE and Flag to generate the interrupt on Falling edge (Cn+1V = FTM Counter)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14273010455598780" jivemacro_uid="_14273010455598780"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;STRONG&gt;__attribute__ &lt;/STRONG&gt;((&lt;/SPAN&gt;&lt;SPAN style="; color: #000080; font-size: 10pt;"&gt;&lt;STRONG&gt;interrupt&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)) &lt;STRONG&gt;DV_Pwm_FTM0IRQ&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="; color: #000080; font-size: 10pt;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)
 &lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-size: 10pt;"&gt;{&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Toggle port debug */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 PTC&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;PTOR &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;|=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;0x00000001&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;
 
 &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;/* Increment Cn+1V */&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnV&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;++&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;
 
 FTM0&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CONTROLS[&lt;/SPAN&gt;&lt;SPAN style="color: #808000; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]&lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;CnSC &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;&amp;amp;=&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 10pt;"&gt;&lt;STRONG&gt;~&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;FTM_CnSC_CHF_MASK; &lt;/SPAN&gt;&lt;SPAN style="; color: #008000; font-size: 10pt;"&gt;&lt;EM&gt;// clear flag
 &lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-size: 10pt;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;
 &lt;/SPAN&gt;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But after test, IT occurs because My debug Pin on PTC0&amp;nbsp; toggle.&lt;/P&gt;&lt;P&gt;But the Cn+1V which is incremented on the Interrupt has no effect on my output signal which should pass from a initial duty cycle of 50% to 100% and then 0%&amp;nbsp; to 100% etc...&lt;/P&gt;&lt;P&gt;But signal still 50% duty!.&lt;/P&gt;&lt;P&gt;SYNCEN is set to 0,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so I don't see why Cn+1V is not impacted?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I read the RM, But I think the Update register should be OK because SYNCEN = 0 &amp;amp; SYNCMODE = 0):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Screen1.jpg"&gt;&lt;IMG alt="Screen1.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/49525iED7A695D72DE10C2/image-size/large?v=v2&amp;amp;px=999" title="Screen1.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Screen2.jpg"&gt;&lt;IMG alt="Screen2.jpg" src="https://community.nxp.com/t5/image/serverpage/image-id/49564i2CCFEC295A09311B/image-size/large?v=v2&amp;amp;px=999" title="Screen2.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:12:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349295#M17124</guid>
      <dc:creator>arnogir</dc:creator>
      <dc:date>2020-11-02T13:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349296#M17125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arno,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you will find that if you FTMEN = 1, you must load the CnV registers according to the PWM Synchronization rules.&amp;nbsp; Meaning that you will need to set the SYNCEN bit in the Combine register and then setup the synchronization according to how you want to synchronize the registers.&amp;nbsp; Here is a snippet of code that will set up your FTM for software synchronization:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14273095732256050" jivemacro_uid="_14273095732256050"&gt;
&lt;P&gt;FTM0_COMBINE |= FTM_COMBINE_SYNCEN0_MASK;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM0_SYNCONF |= (FTM_SYNCONF_SWWRBUF_MASK |&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM_SYNCONF_SWRSTCNT_MASK |&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM_SYNCONF_SYNCMODE_MASK&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should be inserted in your setup code.&amp;nbsp; Once you have this configuration, remember to add a write to the SWSYNC bit after writing your CnV register in your interrupt routine. This write triggers the load of the CnV registers so that they take effect.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14273096448414799" jivemacro_uid="_14273096448414799"&gt;
&lt;P&gt;FTM0_SYNC |= FTM_SYNC_SWSYNC_MASK;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are other ways to control how the registers are loaded when you have FTMEN = 1, but I think this is the simplest fastest method for you at this point.&amp;nbsp; Please let me know if you are interested in other ways or if you have any other questions about this method.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chris &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Mar 2015 18:56:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349296#M17125</guid>
      <dc:creator>chris_brown</dc:creator>
      <dc:date>2015-03-25T18:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349297#M17126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arno Gir,&lt;/P&gt;&lt;P&gt;I think Chris show you the terrific way to update the CnV correctly and please refer to it.&lt;/P&gt;&lt;P&gt;If you have any further question, please just feel free to post.&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ping&lt;/P&gt;&lt;P&gt;&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>Thu, 26 Mar 2015 01:19:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349297#M17126</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2015-03-26T01:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349298#M17127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank for your help, I will test this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I must first make sure this solution does not add jitter on Pwm counter.&lt;/P&gt;&lt;P&gt;In other word, the fact to modify CnV or Cn+1V must not modify other think like FTM counter an then delayed the signal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 06:23:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349298#M17127</guid>
      <dc:creator>arnogir</dc:creator>
      <dc:date>2015-03-26T06:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349299#M17128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After test, it seem not only the modified Cn+1V value is set but also MOD or something else!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The end signal is not that I expected!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With my code, without activate the Interrupt, When I change Cn+1V in a range between 2 to 65535, the signal keep always the same period (determined by CNTIN and MOD) and the the duty cycle evaluate from 0% to 100% according set value in Cn+1V.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I activate the Interrupt in which I make: Cn+1V = Cn+1V&amp;nbsp; + 1&lt;/P&gt;&lt;P&gt;Without your modifications above Cn+1V not change, signal still signal configured in init phase.&lt;/P&gt;&lt;P&gt;With your modifications, Duty cycle is &lt;STRONG&gt;always &lt;/STRONG&gt;about 99.99999% (Always a fast low state) and the period change between "0" (or very small) to my configured period (50MHz / Prescaler (=1) / (MOD-CNTIN)) #1.3ms.. and the restart to 0 etc...&lt;/P&gt;&lt;P&gt;:smileysilly:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 06:36:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349299#M17128</guid>
      <dc:creator>arnogir</dc:creator>
      <dc:date>2015-03-26T06:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349300#M17129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In fact it seems FTM counter is reset when Cn+1V is loaded with&amp;nbsp; new value.&lt;/P&gt;&lt;P&gt;???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 08:22:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349300#M17129</guid>
      <dc:creator>arnogir</dc:creator>
      <dc:date>2015-03-26T08:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349301#M17130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fact I remove the FTM counter syncrhonisation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14273586762174695" jivemacro_uid="_14273586762174695"&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;FTM0&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 10pt;"&gt;-&amp;gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;SYNCONF &lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 10pt;"&gt;|=&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt; (FTM_SYNCONF_SWWRBUF_MASK &lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 10pt;"&gt;|&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; 
 &lt;/SPAN&gt;&lt;EM style=": ; color: #008000; font-size: 10pt;"&gt;//FTM_SYNCONF_SWRSTCNT_MASK |&amp;nbsp; 
 &lt;/EM&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; FTM_SYNCONF_SYNCMODE_MASK&amp;nbsp; 
 );&amp;nbsp; 
 &lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ann add following config:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14273586960316999" jivemacro_uid="_14273586960316999"&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;FTM0&lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 10pt;"&gt;-&amp;gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;SYNC &lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 10pt;"&gt;|=&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt; FTM_SYNC_CNTMIN_MASK;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:12:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349301#M17130</guid>
      <dc:creator>arnogir</dc:creator>
      <dc:date>2020-11-02T13:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349302#M17131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have another problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way explain above, CnV anc Cn+1V (Refresh in Cn+1V IT) are updated on the FTM counter pass from High value (0xFFFF) to low value (0x0000)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in my case, I want in the Cn+1V refresh CnV and Cn+1V and taken immediately in the same FTM cycle, Not wait end of Counter reach max value (MOD), but immediately and then if new CnV / Cn+1V match TMR counter value, modify output and then generate interrupt..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there possible with the FTM?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 08:59:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349302#M17131</guid>
      <dc:creator>arnogir</dc:creator>
      <dc:date>2015-03-26T08:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349303#M17132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arno Gir,&lt;/P&gt;&lt;P&gt;I'm still not very clear with phenomenon after you modify the Cn+1.&lt;/P&gt;&lt;P&gt;So I was wondering if you can explain it again and share your text code, then I reproduce this phenomenon on my board.&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ping&lt;/P&gt;&lt;P&gt;&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>Fri, 27 Mar 2015 09:11:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349303#M17132</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2015-03-27T09:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: FTM generate pulse, Unable to modify CnV register</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349304#M17133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In simple word,&lt;/P&gt;&lt;P&gt;are they a means to update CnV and Cn1V in the CHnIE interrupt (or CHn+1IE) and the new value was taken immediately, without wait next synchronisation on FTM overflow?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Mar 2015 09:22:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTM-generate-pulse-Unable-to-modify-CnV-register/m-p/349304#M17133</guid>
      <dc:creator>arnogir</dc:creator>
      <dc:date>2015-03-27T09:22:27Z</dc:date>
    </item>
  </channel>
</rss>

