<?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>S32KのトピックRe: S32K144 Quadrature Decoder Configuration Issue</title>
    <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927069#M4869</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Diana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to your suggest, I creat a new project in S32 Design Studio but it showed there is no "&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;S32_NVIC". What is the problem ? Is it a must to replace&amp;nbsp;&lt;SPAN&gt;FSL_NVIC by&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;S32_NVIC ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Best,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Jianfei&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Aug 2019 18:33:58 GMT</pubDate>
    <dc:creator>cjf6221</dc:creator>
    <dc:date>2019-08-16T18:33:58Z</dc:date>
    <item>
      <title>S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927067#M4867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;I would like to used FTM2_QD(PTD10, PTD11) to measure every rising or falling edge of A and B by using counter overflow interrupt and then calculate the motor position based on encoder. But&amp;nbsp;I am troubled by the &lt;SPAN&gt;FTM2_QD&lt;/SPAN&gt; configuration for a long time.&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;Below is my configuration for&amp;nbsp;FTM2_QD. Please provide some help.&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;void FTM2_Quadrature_Decoder_Mode()&lt;BR /&gt;{&lt;BR /&gt;/* Enable clock for PORTD */&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_PORTD_INDEX] = PCC_PCCn_CGC_MASK;&lt;BR /&gt;/* Select and enable clock for FTM2 */&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_FLEXTMR2_INDEX] = PCC_PCCn_PCS(6) | PCC_PCCn_CGC_MASK;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;PORTD-&amp;gt;PCR[10] = PORT_PCR_MUX(3); // Set PTD10 for FTM2 - Phase B input&lt;BR /&gt;PORTD-&amp;gt;PCR[11] = PORT_PCR_MUX(3); // Set PTD11 for FTM2 - Phase A input&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;FSL_NVIC-&amp;gt;ISER[FTM2_IRQn / 32] |= (1 &amp;lt;&amp;lt; (FTM2_IRQn % 32)); // Enable FTM2 counter overflow interrupt&lt;BR /&gt;// FSL_NVIC-&amp;gt;ICPR[116/32] = 1 &amp;lt;&amp;lt; (116% 32);&lt;BR /&gt;FSL_NVIC-&amp;gt;ISER[116/32] = 1 &amp;lt;&amp;lt; (116% 32);&amp;nbsp; &amp;nbsp;// overflow interrupt number&lt;BR /&gt;// FSL_NVIC-&amp;gt;IP[116] = 0;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;FTM2-&amp;gt;MODE = FTM_MODE_WPDIS_MASK | FTM_MODE_FTMEN_MASK;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;//Enable FTM2 module (0x00000005): D2(WPDIS) and D0(FTMEN) are set.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;FTM2-&amp;gt;MOD = FTM_MOD_MOD(10);&amp;nbsp;//&amp;nbsp;overflow&amp;nbsp;after totally 4096 rising/falling edges&lt;BR /&gt;FTM2-&amp;gt;CNT = 0;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;FTM2-&amp;gt;CNTIN = FTM_CNTIN_INIT(0);&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;FTM2-&amp;gt;QDCTRL &amp;amp;= ~FTM_QDCTRL_QUADMODE_MASK; // Phase A and phase B encoding mode&lt;BR /&gt; FTM2-&amp;gt;QDCTRL = FTM_QDCTRL_PHAFLTREN_MASK | FTM_QDCTRL_PHBFLTREN_MASK | FTM_QDCTRL_QUADEN_MASK; // Enable QD mode and input filter&lt;BR /&gt;FTM2-&amp;gt;SC |= FTM_SC_CLKS(1) | FTM_SC_PS(2) | FTM_SC_CPWMS_MASK | FTM_SC_TOIE_MASK;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;// FTM_SC_CLKS(1): select FTM as input timer.&lt;BR /&gt;// FTM_SC_PS(2): clock source FTM, prescaler 2^2, clock frequency = 112MHz/4 = 28MHz&lt;BR /&gt;// FTM_SC_TOIE_MASK: enable timer overflow interruption&lt;BR /&gt;// FTM_SC_CPWMS_MASK; D5(CPWMS) is set to enable up-down counting mode&lt;BR /&gt;}&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;STRONG style="border: 0px; font-weight: bold; font-size: 14px;"&gt;Below is the overflow interrupt function.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;void FTM2_Ovf_Reload_IRQHandler()&amp;nbsp;&amp;nbsp;&lt;BR /&gt;{&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;if( FTM2-&amp;gt;SC &amp;amp; FTM_SC_TOF_MASK ){&amp;nbsp; &amp;nbsp;// there is overflow interrupt&lt;BR /&gt;&amp;nbsp; &amp;nbsp; PTC-&amp;gt;PTOR |= 1&amp;lt;&amp;lt;9; // Toggle PTC9 for scope display&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTM2_ISR_Counter++;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Temp_EncoderB = FTM2-&amp;gt;CONTROLS[0].CnV; //store the captured C0V value (Counter's vaule)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Temp_EncoderA = FTM2-&amp;gt;CONTROLS[1].CnV; //store the captured C1V value (Counter's vaule)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTM2-&amp;gt;CONTROLS[0].CnSC &amp;amp;= ~FTM_CnSC_CHF_MASK; //clear Ch0 flag D7(CHF) is required to be reset after reading&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTM2-&amp;gt;CONTROLS[1].CnSC &amp;amp;= ~FTM_CnSC_CHF_MASK; //clear Ch1 flag D7(CHF) is required to be reset after reading&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Count_Encoder = FTM2-&amp;gt;CNT;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTM2-&amp;gt;SC &amp;amp;= ~FTM_SC_TOF_MASK; // Clear timer overflow flag D9(TOF) after reading the&amp;nbsp;&lt;SPAN&gt;captured C0V and C0V1 values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;}&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;}&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;I do not know why there is no output for&amp;nbsp;&lt;SPAN&gt;Temp_EncoderB and&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;Temp_EncoderA.&amp;nbsp;It sounds like the overflow interrupt does not happen. Please provide some help if you know.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px; font-size: 14px;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Jianfei Chen&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Aug 2019 03:13:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927067#M4867</guid>
      <dc:creator>cjf6221</dc:creator>
      <dc:date>2019-08-15T03:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927068#M4868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Rong,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The interrupt does not work because you are using old code/header file where is used FSL_NVIC write.&lt;/P&gt;&lt;P&gt;The S32_NVIC should be used instead of &lt;SPAN&gt;FSL_NVIC in the&amp;nbsp;&lt;/SPAN&gt;new projects.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recommend you to create a new project. After that, the header file will be correct and you can use, for example,&amp;nbsp;code below for initialization of the interrupt:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;S32_NVIC-&amp;gt;ICPR[3] = 1 &amp;lt;&amp;lt; (116 % 32);&lt;BR /&gt;S32_NVIC-&amp;gt;ISER[3] = 1 &amp;lt;&amp;lt; (116 % 32);&lt;BR /&gt;S32_NVIC-&amp;gt;IP[116] = 0x00;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Aug 2019 12:34:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927068#M4868</guid>
      <dc:creator>dianabatrlova</dc:creator>
      <dc:date>2019-08-15T12:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927069#M4869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Diana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to your suggest, I creat a new project in S32 Design Studio but it showed there is no "&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;S32_NVIC". What is the problem ? Is it a must to replace&amp;nbsp;&lt;SPAN&gt;FSL_NVIC by&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;S32_NVIC ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Best,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; "&gt;Jianfei&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Aug 2019 18:33:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927069#M4869</guid>
      <dc:creator>cjf6221</dc:creator>
      <dc:date>2019-08-16T18:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927070#M4870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Rong,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which version of S32 Design Studio do you use?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please, use the newest version S32 Design Studio for Arm 2018.R1:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.nxp.com/webapp/swlicensing/sso/downloadSoftware.sp?catid=S32-DS-ARM_v2018" title="https://www.nxp.com/webapp/swlicensing/sso/downloadSoftware.sp?catid=S32-DS-ARM_v2018"&gt;https://www.nxp.com/webapp/swlicensing/sso/downloadSoftware.sp?catid=S32-DS-ARM_v2018&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2019 06:41:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927070#M4870</guid>
      <dc:creator>dianabatrlova</dc:creator>
      <dc:date>2019-08-19T06:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927071#M4871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Diana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much. The version I used is Arm V1.3. As you said, quadrature encoder is not availablel in Arm V1.3 ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Jianfei&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2019 18:55:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927071#M4871</guid>
      <dc:creator>cjf6221</dc:creator>
      <dc:date>2019-08-22T18:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927072#M4872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe the problem is caused by the interruption type. I used overflow interruption, which&amp;nbsp;maybe not suitable for quadrature encoder mode. What do you think ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Jianfei&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2019 19:59:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927072#M4872</guid>
      <dc:creator>cjf6221</dc:creator>
      <dc:date>2019-08-22T19:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927073#M4873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jianfei,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;really recommend you to&amp;nbsp;install the newest version of the S32DS -&amp;nbsp;&lt;STRONG&gt;S32 Design Studio for Arm 2018.R1 – Windows/Linux(REV 2018-R1)&lt;/STRONG&gt;, after that, it&amp;nbsp;should work:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.nxp.com/design/software/embedded-software/s32-design-studio-ide/s32-design-studio-ide-for-arm-based-mcus:S32DS-ARM?&amp;amp;tab=Design_Tools_Tab" title="https://www.nxp.com/design/software/embedded-software/s32-design-studio-ide/s32-design-studio-ide-for-arm-based-mcus:S32DS-ARM?&amp;amp;tab=Design_Tools_Tab"&gt;S32 Design Studio IDE for Arm® based MCUs | NXP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you seen the maskset when&amp;nbsp;you select the device in v1.3? I'm asking because the v1.3 generates the old header file where the FSL_NVIC is implemented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2019 07:37:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927073#M4873</guid>
      <dc:creator>dianabatrlova</dc:creator>
      <dc:date>2019-08-23T07:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927074#M4874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Diana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to your suggestion, I have installed the newest version of S32DS. Below is the code built in S32-Arm&lt;STRONG style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: bold; font-size: 14px;"&gt;2018.R1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#include "S32K144.h" /* include peripheral declarations S32K144 */&lt;/P&gt;&lt;P&gt;void FTM2_Quadrature_Decoder_Mode();&lt;BR /&gt;uint16_t Temp_EncoderA; //Port D11&lt;BR /&gt;uint16_t Temp_EncoderB; //Port D10&lt;BR /&gt;uint16_t FTM2_ISR_Counter=0;&lt;BR /&gt;uint16_t Count_Encoder = 0;&lt;BR /&gt;uint16_t Pre_Count_Encoder = 0;&lt;BR /&gt;uint16_t Count_Overflow,k;&lt;BR /&gt;uint8_t Motor_TOFDIR_Encoder, Motor_TOF_Encoder; // Timer overflow direction&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; int counter = 0;&lt;BR /&gt; FTM2_Quadrature_Decoder_Mode();&lt;/P&gt;&lt;P&gt;// for(;;) {&lt;BR /&gt;// }&lt;/P&gt;&lt;P&gt;/* to avoid the warning message for GHS and IAR: statement is unreachable*/&lt;BR /&gt;#if defined (__ghs__)&lt;BR /&gt;#pragma ghs nowarning 111&lt;BR /&gt;#endif&lt;BR /&gt;#if defined (__ICCARM__)&lt;BR /&gt;#pragma diag_suppress=Pe111&lt;BR /&gt;#endif&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void FTM2_Quadrature_Decoder_Mode()&lt;BR /&gt;{&lt;BR /&gt; /* Enable clock for PORTD */&lt;BR /&gt; PCC-&amp;gt;PCCn[PCC_PORTD_INDEX] = PCC_PCCn_CGC_MASK; // clock enabled&lt;BR /&gt; /* Select and enable clock for FTM2 */&lt;BR /&gt; PCC-&amp;gt;PCCn[58] |= PCC_PCCn_PCS(6) | PCC_PCCn_CGC_MASK;&lt;BR /&gt;// PORTD-&amp;gt;PCR[4] |= PORT_PCR_MUX(1) | PORT_PCR_IRQC(9);&lt;/P&gt;&lt;P&gt;PORTD-&amp;gt;PCR[10] |= PORT_PCR_MUX(3); // Set PTD10 for FTM2 - Phase B input&lt;BR /&gt; PORTD-&amp;gt;PCR[11] |= PORT_PCR_MUX(3); // Set PTD11 for FTM2 - Phase A input&lt;/P&gt;&lt;P&gt;// S32_NVIC-&amp;gt;ISER[3] |= (1 &amp;lt;&amp;lt; (FTM2_IRQn % 32)); // Enable FTM2 interrupt FTM2_IRQn&lt;BR /&gt; S32_NVIC-&amp;gt;ICPR[3] = (1&amp;lt;&amp;lt;(116%32)); //116/32=3 /* clr any pending IRQ*/&lt;BR /&gt; S32_NVIC-&amp;gt;ISER[3] = (1&amp;lt;&amp;lt;(116%32)); //116/32=3 /* enable IRQ */&lt;BR /&gt; S32_NVIC-&amp;gt;IP[116] = 0x00;&lt;/P&gt;&lt;P&gt;/* Input capture mode sensitive on both rising and falling edges to measure duty cycle of tested signal */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FTM2-&amp;gt;MODE |= FTM_MODE_WPDIS_MASK | FTM_MODE_FTMEN_MASK; // Enable write the FTM CnV register (0x00000004): D2(WPDIS)&lt;BR /&gt; // Enable FTM2 module (0x00000001): D0(FTMEN) are set.FTM_MODE_INIT_MASK&lt;BR /&gt; //enable the counter to run in the BDM mode&lt;BR /&gt; //FTM2-&amp;gt;CONF = FTM_CONF_BDMMODE(3);&lt;BR /&gt; /* Encoder simulation with totally 144 rising/falling edges */&lt;BR /&gt; FTM2-&amp;gt;MOD = FTM_MOD_MOD(10);&lt;BR /&gt; /* Reset counter */&lt;BR /&gt; FTM2-&amp;gt;CNTIN = FTM_CNTIN_INIT(0); // initial value of FTM2 counter&lt;BR /&gt; FTM2-&amp;gt;QDCTRL &amp;amp;= ~FTM_QDCTRL_QUADMODE_MASK; // Phase A and phase B encoding mode&lt;BR /&gt; FTM2-&amp;gt;QDCTRL |= FTM_QDCTRL_QUADEN_MASK; // Enable QD mode.&lt;BR /&gt; FTM2-&amp;gt;QDCTRL &amp;amp;= ~FTM_QDCTRL_TOFDIR_MASK;&lt;BR /&gt; FTM2-&amp;gt;CNT = 0;&lt;BR /&gt; /* Select clock */&lt;BR /&gt; FTM2-&amp;gt;SC |= FTM_SC_CLKS(1) | FTM_SC_PS(4) | FTM_SC_TOIE_MASK;&lt;BR /&gt; // FTM_SC_CLKS(1) selects FTM as input timer.&lt;BR /&gt; // FTM_SC_PS(2); clock source FTM, prescaler 2^2, clock frequency = 112MHz/4 = 28MHz&lt;BR /&gt; // FTM_SC_TOIE_MASK enables timer overflow interruption&lt;BR /&gt; // FTM_SC_CPWMS_MASK; D5(CPWMS) is set to enable up-down counting mode FTM_SC_CPWMS_MASK&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void FTM2_Ovf_Reload_IRQHandler()//this interrupt is FTM2&lt;BR /&gt;//void FTM2_Ch0_Ch1_IRQHandler()//this interrupt is FTM2&lt;BR /&gt;{&lt;BR /&gt; PTA-&amp;gt;PTOR |= 0x0800; //PTA11 is set&lt;BR /&gt; if(FTM2-&amp;gt;SC &amp;amp; FTM_SC_TOF_MASK ){&lt;BR /&gt; Motor_TOFDIR_Encoder = ((FTM2-&amp;gt;QDCTRL)&amp;gt;&amp;gt;1)&amp;amp;0x1; // the QUADIR bit in the FTM_QDCTRL register indicates Timer overflow direction in QD mode&lt;BR /&gt; Motor_TOF_Encoder = ((FTM2-&amp;gt;SC)&amp;gt;&amp;gt;9)&amp;amp;0x1; // Timer overflow flag&lt;BR /&gt; if(Motor_TOFDIR_Encoder){&lt;BR /&gt; Count_Overflow++;&lt;BR /&gt; }else{&lt;BR /&gt; Count_Overflow--;&lt;BR /&gt; }&lt;BR /&gt; Pre_Count_Encoder = Count_Encoder;&lt;BR /&gt; Count_Encoder = Count_Encoder*10 + FTM2-&amp;gt;CNT;&lt;BR /&gt; FTM2-&amp;gt;SC &amp;amp;= ~FTM_SC_TOF_MASK; // Clear timer overflow flag D9(TOF) is reset&lt;BR /&gt; }&lt;BR /&gt; PTA-&amp;gt;PTOR &amp;amp;= 0x7FFF; //PTA11 is reset&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: bold; font-size: 14px;"&gt; I&amp;nbsp;debuged it in Debug_RAM mode and found it cannot enter the overflow interrupt. So &lt;SPAN style="color: #3d3d3d; font-weight: 400;"&gt;FTM2-&amp;gt;CNT has no change. I also tried another interrupt&amp;nbsp;&lt;SPAN&gt;FTM2_Ch0_Ch1_IRQHandler() but still cannot enter the interrupt.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;I was troubled by this issue for so long time.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: bold; font-size: 14px;"&gt;Best,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #51626f; background-color: #ffffff; border: 0px; font-weight: bold; font-size: 14px;"&gt;Jianfei&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Sep 2019 21:41:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927074#M4874</guid>
      <dc:creator>cjf6221</dc:creator>
      <dc:date>2019-09-12T21:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927075#M4875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Rong,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a very simple test code. I'm using S32K144EVB.&lt;/P&gt;&lt;P&gt;There I verify that after the FTM counter reach number 36 (0x24) the interrupt is generated.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/84849i20A8087CCA566804/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2019 13:17:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927075#M4875</guid>
      <dc:creator>dianabatrlova</dc:creator>
      <dc:date>2019-09-20T13:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927076#M4876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Diana,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your patience and kind help. Finally I figured it out and found the FTM2 should be configured to work under debug mode as I would like to debug it under the debug_RAM mode. So the following code must be added.&lt;/P&gt;&lt;P&gt;&amp;nbsp;FTM2-&amp;gt;CONF = FTM_CONF_BDMMODE(3);&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Under this way, the overflow interrrupt is set as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/89620i042343003251E482/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then, quadrature decoder works well and there is the same result as you attached.&amp;nbsp;&lt;SPAN&gt;FTM2-&amp;gt;CNT successfully changes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_3.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/90506i5D8AE43AC016AD4C/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_3.png" alt="pastedImage_3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But here I have one more question. I used overflowed interrupt (TOF) but you suggested reload interrupt (RF) with the code as follows:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/90321i845048CF95043DC0/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Interestingly, the output results are the same. Can you explain why this happen ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2019 14:54:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927076#M4876</guid>
      <dc:creator>cjf6221</dc:creator>
      <dc:date>2019-09-24T14:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: S32K144 Quadrature Decoder Configuration Issue</title>
      <link>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927077#M4877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rong,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm very sorry for the delay. I'm glad that it works.&lt;/P&gt;&lt;P&gt;Actually I'm using TOIE - overflowed interrupt in this code. I'm using this code as a test code (it is not an official example) so, the clearing reload flag RF&amp;nbsp;it's unnecessary. It should not be there.&amp;nbsp;I'm sorry I confused you. There should be clearing TOF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have the interest to know more about reload interrupt I recommend you to read sections in the RM rev 11:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;45.5.29 Reload Points&lt;/EM&gt; and &lt;EM&gt;45.5.29.1 Reload Opportunities&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Oct 2019 13:44:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K144-Quadrature-Decoder-Configuration-Issue/m-p/927077#M4877</guid>
      <dc:creator>dianabatrlova</dc:creator>
      <dc:date>2019-10-08T13:44:56Z</dc:date>
    </item>
  </channel>
</rss>

