<?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 Re: KEA128 PWT help in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660976#M40577</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robin,&lt;/P&gt;&lt;P&gt;thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;@&lt;SPAN&gt;The pwm_rd and pwm_rd1 in your PWT_IRQHandler() seems to be error.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;here pwm_rd and pwm_rd1 are two diffrent uint16_t volatile variables (used in ISR) which i use to get values from NPW and PPW registers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;@&lt;SPAN&gt;o not change any PWT configurations as long as PWTEN is set.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;Now I have changed that line and enabled tha PWT module after configuring the PWT(clock,egde etc..)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;But still, I am not bale to get the result. The thing is that PPW val is not getting update in any case whenever I change the selection bits of EDGE[1:0].&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;ISR is gettting serviced,vals are being printed but only of NPW....&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Dec 2016 09:30:09 GMT</pubDate>
    <dc:creator>maharajshreekum</dc:creator>
    <dc:date>2016-12-12T09:30:09Z</dc:date>
    <item>
      <title>KEA128 PWT help</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660974#M40575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to measure the pulse width of PWM using PWT (Pulse Width Timer) module of KEA128. The frequency which I am measuring is 1Khz(50% duty cycle, can be changed) on PTD5 (PWINT0 channel). I have configured the PWT with bus clock of 20Mhz and pre-scale of 64. I have also enabled the interrupts for Data Ready and PWT interrupt so as to read the PPW (Positive Pulse width) and NPW (Negative PW) values in Reg PWT_R1 and PWT_R2,summing both value to count of one period.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the &amp;nbsp;my code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/************************************************************************************************************/&lt;/P&gt;&lt;P&gt;void PWT_Init(void)&lt;BR /&gt;{&lt;BR /&gt; SIM_SCGC |= SIM_SCGC_PWT_MASK; /* Enable Clock for PWT module */&lt;BR /&gt; &lt;BR /&gt; PWT_R1 |= PWT_R1_PWTEN_MASK; /* Enable PWT module*/&lt;BR /&gt; PWT_R1 |= PWT_R1_PRE(6); /* Set Prescaler: 64. 20 Mhz/64= 312.5KHz.*/&lt;BR /&gt; &lt;BR /&gt; PWT_R1 |= PWT_R1_EDGE(2); /* &lt;SPAN style="color: #000000; font-size: 9pt;"&gt;first falling edge starts measurement, and on all the subsequent rising and falling&amp;nbsp;&lt;SPAN style="color: #000000; font-size: 9pt;"&gt;edges&lt;/SPAN&gt;&lt;/SPAN&gt;*/&lt;BR /&gt; PWT_R1 |= PWT_R1_PWTSR_MASK; /* Soft module reset */&lt;BR /&gt; PWT_R1 |= PWT_R1_PRDYIE_MASK; /* PWT Pulse Width Data Ready Int Enable*/&lt;BR /&gt; PWT_R1 |= PWT_R1_PWTIE_MASK; /* PWT Module Interrupt Enable*/&lt;/P&gt;&lt;P&gt;SIM_PINSEL1 &amp;amp;= ~SIM_PINSEL1_PWTIN0PS_MASK; /* PWT channel mapped to pin PTD5 (PWINT0) */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ISR of PWT is, I have enabled NVIC and all in main......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void PWT_IRQHandler()&lt;BR /&gt;{&lt;BR /&gt; if (((PWT_R1 &amp;amp; PWT_R1_PWTRDY_MASK)&amp;gt;&amp;gt;PWT_R1_PWTRDY_SHIFT == 1))&lt;BR /&gt; { &lt;BR /&gt; LED0_TOGGLE;&lt;BR /&gt; pwm_rd = (PWT_R2 &amp;amp; PWT_R2_NPW_MASK) &amp;gt;&amp;gt; PWT_R2_NPW_SHIFT;&lt;BR /&gt; pwm_rd1 = (PWT_R1 &amp;amp; PWT_R1_PPW_MASK);&lt;BR /&gt; }&lt;BR /&gt; PWT_R1 &amp;amp;= ~PWT_R1_PWTRDY_MASK; /* Clear flag: read reg then write 0 to PWTRDY */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/************************************************************************************************************/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, My problem is that when i am trying to print values of both NPW and PPW in main, only NPW is getting updated but not PPW. PPW is also NOT getting updated even when I change EDGE[1:0] bits to&amp;nbsp;&lt;SPAN&gt;PWT_R1_EDGE(1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For 1Khz input pulse width, the value in NPW is 156, it should be 156 in PPW so that I can calculate how much is the &amp;nbsp;duty cycle of the PWM pulse.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Freq. can be calculated as below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12pt;"&gt;PWT Clock / (PPW ? NPW), PWT Clock = 20Mhz/64 =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;312500/312 = 1000 (!Khz pwm)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Pls shed some light on this, if anybody has done this before. WHERE I AM GOING WRONG!!!!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Dec 2016 12:17:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660974#M40575</guid>
      <dc:creator>maharajshreekum</dc:creator>
      <dc:date>2016-12-09T12:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: KEA128 PWT help</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660975#M40576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;The pwm_rd and pwm_rd1 in your PWT_IRQHandler() seems to be error. Should be like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; u32PositivePulse = (PWT_R1 &amp;amp; PWT_R1_PPW_MASK)&amp;gt;&amp;gt; PWT_R1_PPW_SHIFT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;u32NegativePulse = (PWT_R2 &amp;amp; PWT_R2_NPW_MASK) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid unexpected behavior, do not change any PWT configurations as long as PWTEN is set. I saw that you enabled that bit at the beginning of PWT_Init().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can refer the&amp;nbsp;PWT_Init() in pwt.c.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pwtc.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/11172i40610000F924A6C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="pwtc.png" alt="pwtc.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The pwt.c can be found in below folder. For example: ...:\Program Files\Freescale\S32DS_ARM_v1.3\S32DS\S32_SDK_KEA_1_0_0\sources&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pwt in S32_SDK_KEA_1_0_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/11073i577164F8ABD18684/image-size/large?v=v2&amp;amp;px=999" role="button" title="pwt in S32_SDK_KEA_1_0_0.png" alt="pwt in S32_SDK_KEA_1_0_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The &lt;A href="http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/s32-arm-processors-microcontrollers/s32-design-studio-ide:S32DS"&gt;S32 Design Studio for ARM v1.3 IDE&lt;/A&gt; can be download from &lt;A href="http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/s32-arm-processors-microcontrollers/s32-design-studio-ide:S32DS?tab=Design_Tools_Tab"&gt;here&lt;/A&gt;.&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, 12 Dec 2016 09:04:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660975#M40576</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2016-12-12T09:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: KEA128 PWT help</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660976#M40577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robin,&lt;/P&gt;&lt;P&gt;thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;@&lt;SPAN&gt;The pwm_rd and pwm_rd1 in your PWT_IRQHandler() seems to be error.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;here pwm_rd and pwm_rd1 are two diffrent uint16_t volatile variables (used in ISR) which i use to get values from NPW and PPW registers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;@&lt;SPAN&gt;o not change any PWT configurations as long as PWTEN is set.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;Now I have changed that line and enabled tha PWT module after configuring the PWT(clock,egde etc..)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;But still, I am not bale to get the result. The thing is that PPW val is not getting update in any case whenever I change the selection bits of EDGE[1:0].&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;ISR is gettting serviced,vals are being printed but only of NPW....&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Dec 2016 09:30:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660976#M40577</guid>
      <dc:creator>maharajshreekum</dc:creator>
      <dc:date>2016-12-12T09:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: KEA128 PWT help</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660977#M40578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Please see the Register of PWT_R1 and PWT_R2 first.&lt;/P&gt;&lt;P&gt;The PositivePulse = (PWT_R1 &amp;amp; PWT_R1_PPW_MASK)&amp;gt;&amp;gt; PWT_R1_PPW_SHIFT; due to it's located at the higher 16bits.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="PPW PWT_R1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9794i427C26995153E8D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="PPW PWT_R1.png" alt="PPW PWT_R1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The NegativePulse = (PWT_R2 &amp;amp; PWT_R2_NPW_MASK) ; due to it's located at the lower 16bits.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="NPW PWT_R2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9796i1C812CF123AE7DEB/image-size/large?v=v2&amp;amp;px=999" role="button" title="NPW PWT_R2.png" alt="NPW PWT_R2.png" /&gt;&lt;/span&gt;&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 01:00:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660977#M40578</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2016-12-13T01:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: KEA128 PWT help</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660978#M40579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OHHH!!!...Thanks Robin...I just misread the registers,a very basic mistake....&lt;/P&gt;&lt;P&gt;Thanks a lot....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 05:40:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA128-PWT-help/m-p/660978#M40579</guid>
      <dc:creator>maharajshreekum</dc:creator>
      <dc:date>2016-12-13T05:40:13Z</dc:date>
    </item>
  </channel>
</rss>

