<?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: FlexTimer for Quadrature Decoder on K66 - How to</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FlexTimer-for-Quadrature-Decoder-on-K66-How-to/m-p/1016803#M56192</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xabier,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I highly recommend you to check our SDK examples we offer for K66 devices. You can find&lt;STRONG&gt; ftm_quad_decoder&lt;/STRONG&gt; demo that describes the usage of Quad Decoder feature in FTM module, which can be used to count the position of decoder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can download our SDK from the following link:&amp;nbsp;&lt;A class="link-titled" href="https://mcuxpresso.nxp.com/en/welcome" title="https://mcuxpresso.nxp.com/en/welcome"&gt;Welcome | MCUXpresso SDK Builder&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Mar 2020 21:52:22 GMT</pubDate>
    <dc:creator>FelipeGarcia</dc:creator>
    <dc:date>2020-03-02T21:52:22Z</dc:date>
    <item>
      <title>FlexTimer for Quadrature Decoder on K66 - How to</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FlexTimer-for-Quadrature-Decoder-on-K66-How-to/m-p/1016802#M56191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I own a Teensy 3.6 which runs a K66. I am currently trying to read the pulses of an encoder using the Quadrature Decoder mode of the FlexTimer Module 1 (FTM1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all, I don't have the encoder with me, so I simulated the signals using the FTM0 Output Compare with the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//initialise Flextimer 1&lt;BR /&gt; FTM0_MODE = 0x05; //set write-protect disable (WPDIS) bit to modify other registers&lt;BR /&gt; //FAULTIE=0, FAULTM=00, CAPTEST=0, PWMSYNC=0, WPDIS=1, INIT=0, FTMEN=1(no restriction FTM)&lt;BR /&gt; FTM0_SC = 0x00; //set status/control to zero = disabled (enabled in main loop)&lt;BR /&gt; FTM0_CNT = 0x0000; //reset count to zero&lt;BR /&gt; FTM0_MOD = FTM1MODCount; //max modulus = 23 (gives count = 24 on roll-over - 1 MHz)&lt;BR /&gt; FTM0_C0SC = 0x14; // CHF=0, CHIE=0 (disable interrupt), MSB=0 MSA=1, ELSB=0 ELSA=1 (output compare - toggle), 0, DMA=0&lt;BR /&gt; FTM0_C1SC = 0x14; // CHF=0, CHIE=0 (disable interrupt), MSB=0 MSA=1, ELSB=0 ELSA=1 (output compare - toggle), 0, DMA=0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//configure Teensy pins as outputs&lt;BR /&gt; PORTC_PCR1 = PORT_PCR_MUX(0x4); &lt;BR /&gt; PORTC_PCR2 = PORT_PCR_MUX(0x4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//enable system clock (48 MHz), no prescale&lt;BR /&gt; FTM0_C0V = 0; //compare value = 0&lt;BR /&gt; FTM0_C1V = 0x8000; //compare value = 12&lt;BR /&gt; FTM0_SC = 0x0A; // (Note - FTM0_SC [TOF=0 TOIE=0 CPWMS=0 CLKS=01 (System Clock 48 MHz) PS=000 [no prescale divide])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code works, as I can see the Pulses of 114 Hz on my osciloscope, so I don't think this is part of the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, I run the following code in order to set the QD mode on my FTM1 (which is supported by the FTM1 in the K66):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SIM_SCGC6|=0x03000000; //enable FTM1 module clock&lt;/P&gt;&lt;P&gt;PORTA_PCR12 |= 0x300; //MUX = alternative function 3 on Chip Pin 28 (FTM1_CH0) = Teensy Pin 3&lt;BR /&gt; PORTA_PCR13 |= 0x300; //MUX = alternative function 3 on Chip Pin 29 (FTM1_CH1) = Teensy Pin 4&lt;/P&gt;&lt;P&gt;FTM1_MODE = 0x04;&lt;BR /&gt; FTM1_MODE = 0x05;&lt;BR /&gt; FTM1_C0SC = 0; //54&lt;BR /&gt; FTM1_C1SC = 0;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; FTM1_CNT = 0;&lt;BR /&gt; FTM1_MOD = 0;&lt;BR /&gt; FTM1_C0SC = 0b00011100; // Set dual-capture both edges&lt;BR /&gt; FTM1_C1SC = 0b00011100; //&amp;nbsp;&lt;SPAN&gt;Set dual-capture both edges&lt;/SPAN&gt;&lt;BR /&gt; FTM1_SC = 0;&lt;BR /&gt; FTM1_MOD = 0xFFFF;&lt;BR /&gt; FTM1_CNTIN = 0; &lt;BR /&gt; FTM1_QDCTRL = 0x1;&lt;BR /&gt; FTM1_CNT = 0;&lt;/P&gt;&lt;P&gt;FTM1_SC=0x8;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this code I know the following. The MOD register gets modified, the CNT does not count up nor down and the QDCTRL enable bit is set high. I have tryed this code both using the FTM1_CnSC registers and without them (when use them, the CHF bit (interrupt flag) always goes up, even if I disable the interrupts).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone can help me, I would really appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: I have first tryed reading the other questions on this topic from the Forum, but could not get it working anyways.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2020 08:27:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FlexTimer-for-Quadrature-Decoder-on-K66-How-to/m-p/1016802#M56191</guid>
      <dc:creator>xabier_arauzo</dc:creator>
      <dc:date>2020-02-26T08:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: FlexTimer for Quadrature Decoder on K66 - How to</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FlexTimer-for-Quadrature-Decoder-on-K66-How-to/m-p/1016803#M56192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xabier,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I highly recommend you to check our SDK examples we offer for K66 devices. You can find&lt;STRONG&gt; ftm_quad_decoder&lt;/STRONG&gt; demo that describes the usage of Quad Decoder feature in FTM module, which can be used to count the position of decoder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can download our SDK from the following link:&amp;nbsp;&lt;A class="link-titled" href="https://mcuxpresso.nxp.com/en/welcome" title="https://mcuxpresso.nxp.com/en/welcome"&gt;Welcome | MCUXpresso SDK Builder&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Mar 2020 21:52:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FlexTimer-for-Quadrature-Decoder-on-K66-How-to/m-p/1016803#M56192</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2020-03-02T21:52:22Z</dc:date>
    </item>
  </channel>
</rss>

