<?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: using clock() function time.h</title>
    <link>https://community.nxp.com/t5/MPC5xxx/using-clock-function-time-h/m-p/735802#M10097</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;Return code -1 is correct, because the microcontroller does not have any resources, how to return you correct time.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the clock function description:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; text-indent: .05pt;"&gt;&lt;STRONG style="font-size: 9pt; font-family: 'Segoe UI',sans-serif;"&gt;This function returns the calling process' current CPU time. If the CPU time is not available or cannot be &lt;/STRONG&gt;&lt;STRONG style="font-size: 9pt; font-family: 'Segoe UI',sans-serif;"&gt;represented, clock returns the value (clock_t)(-1). &lt;/STRONG&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this is the time function description:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; text-indent: .05pt;"&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Segoe UI',sans-serif;"&gt;The time function returns the current calendar time as a value of type time_t. If the argument result is not a null pointer, the calendar time value is also stored in *result. If the current calendar time is not available, the value &lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Segoe UI',sans-serif;"&gt;(time_t)(-1) is returned. &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px; margin-bottom: .0001pt; text-indent: .05pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you cannot simply use these functions. The way, how to use these functions exists, but it will be pretty difficult and I do not have any experience with it. Please look at the follow&amp;nbsp; URL:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F15030123%2Fhow-does-the-clock-function-in-ctime-access-the-system-clock" rel="nofollow" target="_blank"&gt;http://stackoverflow.com/questions/15030123/how-does-the-clock-function-in-ctime-access-the-system-clock&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&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>Mon, 26 Mar 2018 10:39:22 GMT</pubDate>
    <dc:creator>martin_kovar</dc:creator>
    <dc:date>2018-03-26T10:39:22Z</dc:date>
    <item>
      <title>using clock() function time.h</title>
      <link>https://community.nxp.com/t5/MPC5xxx/using-clock-function-time-h/m-p/735801#M10096</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 am trying to use time.h file clock() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code. I am getting -1 as return value for clock() fucntion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is going wrong here, can someone explain&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "derivative.h" /* include peripheral declarations */&lt;BR /&gt;#include &amp;lt;time.h&amp;gt;&lt;BR /&gt;#include "MPC577xC.h"&lt;BR /&gt;void delay(int milliseconds);&lt;BR /&gt;extern void xcptn_xmpl(void);&lt;/P&gt;&lt;P&gt;void delay(int milliseconds)&lt;BR /&gt;{&lt;BR /&gt; clock_t ticks1 = clock(), ticks2 = ticks1;&lt;BR /&gt; clock_t target = milliseconds * CLOCKS_PER_SEC;&lt;BR /&gt; while ( ( ticks2 - ticks1) &amp;lt; target)&lt;BR /&gt; ticks2 = clock();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; volatile int counter = 0;&lt;BR /&gt; int x;&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;xcptn_xmpl (); /* Configure and Enable Interrupts */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;SIU.PCR[114].R= 0x0200;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SIU.GPDO[114].B.PDOn = 0x0;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for(x=0;x&amp;lt;10;x++)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SIU.GPDO[114].R = 1;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;delay(250);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SIU.GPDO[114].R = 0;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Mar 2018 06:08:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/using-clock-function-time-h/m-p/735801#M10096</guid>
      <dc:creator>vrushalitaklika</dc:creator>
      <dc:date>2018-03-26T06:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: using clock() function time.h</title>
      <link>https://community.nxp.com/t5/MPC5xxx/using-clock-function-time-h/m-p/735802#M10097</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;Return code -1 is correct, because the microcontroller does not have any resources, how to return you correct time.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the clock function description:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; text-indent: .05pt;"&gt;&lt;STRONG style="font-size: 9pt; font-family: 'Segoe UI',sans-serif;"&gt;This function returns the calling process' current CPU time. If the CPU time is not available or cannot be &lt;/STRONG&gt;&lt;STRONG style="font-size: 9pt; font-family: 'Segoe UI',sans-serif;"&gt;represented, clock returns the value (clock_t)(-1). &lt;/STRONG&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this is the time function description:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; text-indent: .05pt;"&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Segoe UI',sans-serif;"&gt;The time function returns the current calendar time as a value of type time_t. If the argument result is not a null pointer, the calendar time value is also stored in *result. If the current calendar time is not available, the value &lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Segoe UI',sans-serif;"&gt;(time_t)(-1) is returned. &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px; margin-bottom: .0001pt; text-indent: .05pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you cannot simply use these functions. The way, how to use these functions exists, but it will be pretty difficult and I do not have any experience with it. Please look at the follow&amp;nbsp; URL:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F15030123%2Fhow-does-the-clock-function-in-ctime-access-the-system-clock" rel="nofollow" target="_blank"&gt;http://stackoverflow.com/questions/15030123/how-does-the-clock-function-in-ctime-access-the-system-clock&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&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>Mon, 26 Mar 2018 10:39:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/using-clock-function-time-h/m-p/735802#M10097</guid>
      <dc:creator>martin_kovar</dc:creator>
      <dc:date>2018-03-26T10:39:22Z</dc:date>
    </item>
  </channel>
</rss>

