<?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>MPC5xxxのトピックRe: Why unexpected delay using RTC while reading CVAL?</title>
    <link>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487342#M2415</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/PetrS"&gt;PetrS&lt;/A&gt;​ can you please help me through this sir?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 May 2016 08:34:42 GMT</pubDate>
    <dc:creator>akshaydaga</dc:creator>
    <dc:date>2016-05-20T08:34:42Z</dc:date>
    <item>
      <title>Why unexpected delay using RTC while reading CVAL?</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487339#M2412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wrote a “&lt;STRONG&gt;_delay_PIT0_ms()&lt;/STRONG&gt;” function using PIT0,&lt;/P&gt;&lt;P&gt;When I try to generate delay of 1 mSec using this function, Some unexpected delay gets generated.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;**&lt;/STRONG&gt;This unexpected delay is generated when I try to read &lt;STRONG&gt;CVAL&lt;/STRONG&gt; but It gives Proper output when I read &lt;STRONG&gt;TIF&lt;/STRONG&gt; flag instead of &lt;STRONG&gt;CVAL&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Why Reading &lt;STRONG&gt;CVAL&lt;/STRONG&gt; is creating problem? What’s the reason behind it?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to read &lt;STRONG&gt;CVAL&lt;/STRONG&gt; for &lt;STRONG&gt;Speed calculation of motor&lt;/STRONG&gt;. So please help me through this and please explain what the problem with “&lt;STRONG&gt;CVAL&lt;/STRONG&gt;” reading is?&lt;/P&gt;&lt;P&gt;and &lt;STRONG&gt;How to Configure Clock to PIT module? (In my case it's 64MHz by default)&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/************************************************************************************************************************/&lt;/P&gt;&lt;P&gt;void &lt;STRONG&gt;_delay_PIT0_ms&lt;/STRONG&gt;(vuint32_t d)&lt;/P&gt;&lt;P&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Maximum Delay can be 67100 miliSeconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (d&amp;lt;=67100)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIT.PITMCR.B.FRZ = 1;&amp;nbsp; //FRZ = 1 for Timers stopped in debug mode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIT.PITMCR.B.MDIS = 0; //MDIS = 0 to enable clock for PITs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIT.CH[0].TCTRL.B.TEN = 0; //TEN = 0 for timer disabled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIT.CH[0].LDVAL.R = (d*64000) - 1;&amp;nbsp; //(64000 = 1mSec)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIT.CH[0].TCTRL.B.TEN = 1; //TEN = 1 for timer active&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;while((PIT.CH[0].CVAL.B.TVL) != 0){};&lt;/STRONG&gt; //Wait till d seconds (i.e. till current timer value reaches to 0)&amp;nbsp; \&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Gives unexpected delay&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //while(PIT.CH[0].TFLG.B.TIF != 1){}; //Works properly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIT.CH[0].TFLG.B.TIF = 1;&amp;nbsp; //Clear Timer Interrupt Flag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIT.CH[0].TCTRL.B.TEN = 0;//TEN = 0 for timer disabled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int32_t&lt;STRONG&gt; main&lt;/STRONG&gt;(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int32_t i = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitHW();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Init_eMIOS();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Init_ADC();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Init_EIRQ();&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Init_BLDC_6x2_3Ph();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Switch_PWM_DutyCycle(INITIAL_A_VAL);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Init_Interrupts();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LED1_TOGGLE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _delay_PIT0_ms(1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LED1_TOGGLE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _delay_PIT0_ms(1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/*********************************************************************************************************************/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2016 20:02:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487339#M2412</guid>
      <dc:creator>akshaydaga</dc:creator>
      <dc:date>2016-05-19T20:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why unexpected delay using RTC while reading CVAL?</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487340#M2413</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 searched in the reference manual and there is no notice about reading CVAL. But I recommend you to read TIF flag. This is correct way, how to check that timeout was reached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the second case, when you check CVAL, it seems the PIT counted is too fast and the condition in while loop is still true (you miss the moment when CVAL is equal to 0) and this causes the problem with delay. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 08:09:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487340#M2413</guid>
      <dc:creator>martin_kovar</dc:creator>
      <dc:date>2016-05-20T08:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why unexpected delay using RTC while reading CVAL?</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487341#M2414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Initially, I also thought the same that somehow due to speed mismatch While() is not getting executed properly. &lt;/P&gt;&lt;P&gt;Then I tried this condition also &lt;STRONG style="color: #51626f; background: white; font-size: 10.5pt; font-family: 'Arial','sans-serif';"&gt;while((PIT.CH[0].CVAL.B.TVL) &amp;lt;= 25){};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Arial','sans-serif'; color: #51626f; background: white;"&gt;But still it is not working. This means speed mismatch should not be the case.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I need to read CVAL value to calculate speed of the motor by reading CVAL values in different interrupts.&lt;/P&gt;&lt;P&gt;Here, It is mentioned that we can read the CVAL value, But I want to know what is correct way to read CVAL?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/27234i30EEF67F88C49276/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&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/3502iD0DEDFACA707124C/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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 08:31:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487341#M2414</guid>
      <dc:creator>akshaydaga</dc:creator>
      <dc:date>2016-05-20T08:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Why unexpected delay using RTC while reading CVAL?</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487342#M2415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/PetrS"&gt;PetrS&lt;/A&gt;​ can you please help me through this sir?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 08:34:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487342#M2415</guid>
      <dc:creator>akshaydaga</dc:creator>
      <dc:date>2016-05-20T08:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why unexpected delay using RTC while reading CVAL?</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487343#M2416</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;Martin was correct, you should use the channel flag to determine the time interval is gone.&lt;/P&gt;&lt;P&gt;Using the CVAL value, the condition could not be always fulfilled. You can easily missed some if using&lt;/P&gt;&lt;P&gt;while((PIT.CH[0].CVAL.B.TVL) != 0){}; statement.&lt;/P&gt;&lt;P&gt;Similarly while((PIT.CH[0].CVAL.B.TVL) &amp;lt;= 25){}; is little bit useless, it will stays in loop for very short time.&lt;/P&gt;&lt;P&gt;Try to use while((PIT.CH[0].CVAL.B.TVL) &amp;gt; 25){}; but still using channel flag polling you get the best result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR, Petr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 10:31:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Why-unexpected-delay-using-RTC-while-reading-CVAL/m-p/487343#M2416</guid>
      <dc:creator>PetrS</dc:creator>
      <dc:date>2016-05-20T10:31:31Z</dc:date>
    </item>
  </channel>
</rss>

