<?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 to estimate clock cycles? in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173774#M5552</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Henry,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had success with using full chip simulation mode, which does have a cycle counter.&amp;nbsp; This&amp;nbsp;should work provided&amp;nbsp;you are not waiting for a hardware event to occur within the code you are testing, and provided you are not attempting to program/erase flash memory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The total CPU cycles will be affected by any&amp;nbsp;potential interrupt execution.&amp;nbsp; However, it should be possible to separately measure the cycles for the execution of&amp;nbsp;each ISR code, to take these into account for a worst case estimation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suggest that you&amp;nbsp;give full chip simulation at try.&amp;nbsp; If it is not suitable for your application, you can then revert to the timer methods previously outlined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Jan 2011 01:28:54 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2011-01-07T01:28:54Z</dc:date>
    <item>
      <title>How to estimate clock cycles?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173771#M5549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am using the&amp;nbsp;MC9S08AC128 and want to have a simple way to find out the number of clock cycles to&amp;nbsp;execute from one C program line to another C program line.&amp;nbsp; There might be a big for loop within this C code segment, and&amp;nbsp;it could take up to one second to execute.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried studying the LST file with the generated assembly instructions and clock cycles, but I have to manually&amp;nbsp;add up the number of clock cycles to run&amp;nbsp;a loop, and multuiply it by the loop count, which&amp;nbsp;seem&amp;nbsp;not&amp;nbsp;a very smart&amp;nbsp;method.&amp;nbsp; Then I try to use an internal timer to find out the clock cycles, but the timer is only 16-bit which cannot go beyond a few tens of milliseconds.&amp;nbsp; Besides, I don't want to waste a hardware&amp;nbsp;timer just for this purpose. &amp;nbsp;Then I tried using the profiling, which is very hard to use, and the trace buffer seems to be only 300 cycles, which is less than what I need.&amp;nbsp; Moreover, the trace only trace result only shows the execution, it does not add up the clock cycles.&amp;nbsp; It also seems to slow&amp;nbsp;down the normal execution of the program which is not acceptable as I have to interface&amp;nbsp;run it with hardware drivers together.&amp;nbsp;&amp;nbsp;Shouldn't there be a more simple way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have use another IDE environment, and they have a clock counter.&amp;nbsp; All I need to do&amp;nbsp;is set two breakpoints at A and B locations.&amp;nbsp; Execute the code to location A,&amp;nbsp;reset the clock counter,&amp;nbsp;then execute the code&amp;nbsp;to location B, and it will show the number of&amp;nbsp;clock cycles.&amp;nbsp; This is the simple thing I am talking about.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR - Henry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Jan 2011 17:12:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173771#M5549</guid>
      <dc:creator>HYIU</dc:creator>
      <dc:date>2011-01-05T17:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to estimate clock cycles?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173772#M5550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If using the internal timer, you would of course need to count the number of timer overflow interrupts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The easiest way however, is to drive an I/O pin high at the beginning of the code, then drive it low at the end. Measure with your oscilloscope. You cannot develop embedded software without one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Jan 2011 17:34:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173772#M5550</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2011-01-05T17:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to estimate clock cycles?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173773#M5551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately there's no dedicated cycle counter in your MCU, which could be read by debugger. I think debugger could show you execution time only (I think&amp;nbsp;NoICE&amp;nbsp;has such feature). Simulator can count cycles, but simulators usage is very limited.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For short delays I'm using timer. For long delays you may use some periodic interrupt and increment&amp;nbsp;counter variable in ISR. Take the difference of counter at point A and at point B, then&amp;nbsp;multiply it by interrupt period expressed in CPU cycles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Jan 2011 18:03:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173773#M5551</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-01-05T18:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to estimate clock cycles?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173774#M5552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Henry,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have had success with using full chip simulation mode, which does have a cycle counter.&amp;nbsp; This&amp;nbsp;should work provided&amp;nbsp;you are not waiting for a hardware event to occur within the code you are testing, and provided you are not attempting to program/erase flash memory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The total CPU cycles will be affected by any&amp;nbsp;potential interrupt execution.&amp;nbsp; However, it should be possible to separately measure the cycles for the execution of&amp;nbsp;each ISR code, to take these into account for a worst case estimation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suggest that you&amp;nbsp;give full chip simulation at try.&amp;nbsp; If it is not suitable for your application, you can then revert to the timer methods previously outlined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 01:28:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173774#M5552</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2011-01-07T01:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to estimate clock cycles?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173775#M5553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all of your help.&amp;nbsp; I have tried using a pin and scope method, and I have tried using simulator with cycle counter.&amp;nbsp; They both worked well and the result&amp;nbsp;seems to match quite good.&amp;nbsp; I have not tried with interrupt timer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2011 13:43:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/How-to-estimate-clock-cycles/m-p/173775#M5553</guid>
      <dc:creator>HYIU</dc:creator>
      <dc:date>2011-01-07T13:43:28Z</dc:date>
    </item>
  </channel>
</rss>

