<?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: How can I measure the execution time of a function? in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590206#M22036</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you for your reply.&lt;/P&gt;&lt;P&gt;Yes, I saw this thread and I'll read it again now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running my code on a cortex m4. I have the LPC-Link2 for debugging.&lt;/P&gt;&lt;P&gt;I'll also look it up whether I have to implement __sys_time() anywhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll let you know the result :smileyhappy:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jun 2016 21:51:33 GMT</pubDate>
    <dc:creator>julianhoerz</dc:creator>
    <dc:date>2016-06-29T21:51:33Z</dc:date>
    <item>
      <title>How can I measure the execution time of a function?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590204#M22034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The command "clock()" doesn't work correct for me, also the command "time()". &lt;/P&gt;&lt;P&gt;It always returns the 2^32-1. &lt;/P&gt;&lt;P&gt;My code looks like this:&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;P&gt;clock_t begin = clock();&lt;/P&gt;&lt;P&gt;my_algo();&lt;/P&gt;&lt;P&gt;clock_t end = clock();&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Normally the values of the variables should be different but in both variables (begin and end) are the same numbers... Always 4294967295 (2^32-1).&lt;/P&gt;&lt;P&gt;I am using a LPC4357 with LPCXpresso 8.1.4.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The clock-function comes from time.h from redlib....&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot use the RTC example from LPC Open, because it can only count seconds....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 20:43:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590204#M22034</guid>
      <dc:creator>julianhoerz</dc:creator>
      <dc:date>2016-06-29T20:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I measure the execution time of a function?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590205#M22035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you read this thread?&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.lpcware.com/content/forum/time-does-nothing" title="https://www.lpcware.com/content/forum/time-does-nothing"&gt;time () does nothing | www.LPCware.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i.e you&amp;nbsp; have to implement __sys_time() yourself as the library has no idea of your hardware. It has to run on any cortex microcontoller.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 21:40:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590205#M22035</guid>
      <dc:creator>thefallguy</dc:creator>
      <dc:date>2016-06-29T21:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I measure the execution time of a function?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590206#M22036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you for your reply.&lt;/P&gt;&lt;P&gt;Yes, I saw this thread and I'll read it again now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running my code on a cortex m4. I have the LPC-Link2 for debugging.&lt;/P&gt;&lt;P&gt;I'll also look it up whether I have to implement __sys_time() anywhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll let you know the result :smileyhappy:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 21:51:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590206#M22036</guid>
      <dc:creator>julianhoerz</dc:creator>
      <dc:date>2016-06-29T21:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I measure the execution time of a function?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590207#M22037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thank you for your help! You're right!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had to make it via semihosting: &lt;A href="http://support.code-red-tech.com/CodeRedWiki/WhatIsSemiHosting" title="http://support.code-red-tech.com/CodeRedWiki/WhatIsSemiHosting"&gt;WhatIsSemiHosting - ** Code Red Support Site **&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I linked the main application against semihosting in the project properties and enabled semihosting in the board.h&lt;/P&gt;&lt;P&gt;Here did I find the solution: &lt;A href="https://community.nxp.com/thread/389140"&gt;Using printf()&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you! :smileyhappy:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jun 2016 22:45:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590207#M22037</guid>
      <dc:creator>julianhoerz</dc:creator>
      <dc:date>2016-06-29T22:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I measure the execution time of a function?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590208#M22038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;To measure the executiotime of my functions, i set a portbit at the begin and clear it at the end of the function.&lt;/P&gt;&lt;P&gt;With an Oscilloscope i can read the Pulsewidth.&lt;/P&gt;&lt;P&gt;Know, that the times differ to the Compiler Optimization settings.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jun 2016 13:21:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590208#M22038</guid>
      <dc:creator>berndsirozynski</dc:creator>
      <dc:date>2016-06-30T13:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I measure the execution time of a function?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590209#M22039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can count the number of cpu cycles or instructions by using the Data Watchpoint and Tracing feature (DWT) of ARM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example code tested on LPC1549:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;// enable the use DWT&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *DEMCR = *DEMCR | 0x01000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Reset cycle counter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *DWT_CYCCNT = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enable cycle counter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *DWT_CONTROL = *DWT_CONTROL | 1 ;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; uint32_t cpuCycles =&amp;nbsp; *DWT_CYCCNT;;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;/* Do something */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpuCycles = *DWT_CYCCNT-cpuCycles;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float time=1.0*cpuCycles/Chip_Clock_GetSystemClockRate();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2016 10:13:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-can-I-measure-the-execution-time-of-a-function/m-p/590209#M22039</guid>
      <dc:creator>martinlorenz</dc:creator>
      <dc:date>2016-07-01T10:13:31Z</dc:date>
    </item>
  </channel>
</rss>

