<?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: Time measurement in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681286#M13974</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;Perhaps you could explain: - If I am reading the value in TPM2 count register - that contains the number of ticks since I enabled FreeCntr16 so is that not the most accurate measurement possible? If i only need a 16-bit result and no interrupt, Is there a method to start, stop and reset TPM2 directly so that I don't need FreeCntr16 at all? In real time the elapsed time will be between 0.5mS and 15mS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Jul 2017 08:28:00 GMT</pubDate>
    <dc:creator>juliancox</dc:creator>
    <dc:date>2017-07-17T08:28:00Z</dc:date>
    <item>
      <title>Time measurement</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681280#M13968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having a problem with time measurement in an application that I am developing using a S08SH. I am using (Processor Expert) FC1:FreeCntr with timer TPM10 to generate an interrupt every 5mS. This works fine. I am then trying to use &amp;nbsp;FC161:FreeCntr16 with timer TPM20 to measure a time interval: -&lt;/P&gt;&lt;P&gt;In the&amp;nbsp;&lt;SPAN&gt;FC1:FreeCntr ISR I start the FC161 timer. A separate software event stops the timer and I read the elapsed time - except that it doesn't work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To investigate the problem I created a simple simulation project.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN style="color: #931a68;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;STRONG&gt;FC1_OnInterrupt&lt;/STRONG&gt;(&lt;SPAN style="color: #931a68;"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;SPAN style="font-size: 15px;"&gt;{&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="color: #931a68; font-size: 10px;"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;char&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; r,s;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="color: #931a68; font-size: 10px;"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;STRONG&gt;unsigned&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;int&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; Time;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;r = FC161_Enable();&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #931a68;"&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;&lt;/SPAN&gt;(s=0;s&amp;lt;50;s++); &amp;nbsp; &amp;nbsp; &amp;nbsp;// a simple delay loop&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;SPAN class="" style="font-size: 15px;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;Time = TPM2CNT; &amp;nbsp; &amp;nbsp; &amp;nbsp;// read the ticks&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;r = FC161_Reset(); &amp;nbsp; &amp;nbsp; // set the breakpoint here&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;SPAN style="font-size: 15px;"&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;r = FC161_Disable();&lt;/SPAN&gt;&lt;/H1&gt;&lt;H1 style="font-size: 10px;"&gt;&lt;SPAN class="" style="font-size: 15px;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 15px;"&gt;}&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;The value in TPM2CNT was always wrong and the only it would work was if I set a breakpoint somewhere in the ISR and then manually changed registers&amp;nbsp;TPM20SC from 0xD0 to 0x50 and TPM2MOD from 0x0003 to 0xFFFF. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px;"&gt;TPM2CNT then held a value that related to the duration of the simple delay loop. However, I cannot find a way to set these register values for FC161:FreeCntr16 using the component Inspector in Processor Expert.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Jul 2017 22:54:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681280#M13968</guid>
      <dc:creator>juliancox</dc:creator>
      <dc:date>2017-07-03T22:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Time measurement</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681281#M13969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Further to the above it appears that the only register that I have to change is TPM2MOD. I was able to change the value &amp;nbsp; by changing the FC161 resolution from 1uS (3) to 16mS (0xF9FF), but I don't know if this is the correct way to do things. All I want is a counter that will start when software tells it to start and stop when software tells it to stop, at which point software can read the number of ticks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Jul 2017 11:06:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681281#M13969</guid>
      <dc:creator>juliancox</dc:creator>
      <dc:date>2017-07-04T11:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Time measurement</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681282#M13970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cox.&lt;/P&gt;&lt;P&gt;To check your problem we need more information.&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&amp;nbsp; &amp;nbsp;your CW version: &lt;BR /&gt;&amp;nbsp; - if you use classic version: Start the IDE and click on Help | About Freescale CodeWarrior. Click on Installed Products.Save all info displayed into a txt file and send it to me.&lt;BR /&gt;&amp;nbsp; - if you use eclipse version: Start the IDE and click on Help | About CodeWarrior Development Studio. Send me the version and build id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. your demo project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus I can test it directly from my side.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jennie Zhang&lt;/P&gt;&lt;P&gt;&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>Wed, 05 Jul 2017 06:09:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681282#M13970</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2017-07-05T06:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Time measurement</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681283#M13971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jennie, please call me Julian - it sounds less formal.&lt;/P&gt;&lt;P&gt;My CW installation is Version 10.7 Build Id: 160721&lt;/P&gt;&lt;P&gt;I hope I have done the next step correctly - I have never used this facility&lt;/P&gt;&lt;P&gt;I used the export wizard &amp;gt; Export | General | Archive file&lt;/P&gt;&lt;P&gt;I selected the project in the left hand window and all files in the right hand window.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Jul 2017 10:03:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681283#M13971</guid>
      <dc:creator>juliancox</dc:creator>
      <dc:date>2017-07-05T10:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Time measurement</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681284#M13972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jennie&lt;/P&gt;&lt;P&gt;Any signs of a solution?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2017 10:06:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681284#M13972</guid>
      <dc:creator>juliancox</dc:creator>
      <dc:date>2017-07-12T10:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Time measurement</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681285#M13973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Julian,&lt;/P&gt;&lt;P&gt;Sorry for the late, I was not in office this week thus I don't have a SH4 board in hand now.&lt;/P&gt;&lt;P&gt;However I checked your code you use FreeCntr16 component tor TPM2 counting. This is counter for long time period. I suggest you use FreeCntr for TPM2 instead. See how it works?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will test your code with board once I get to office next week.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jennie Zhang&lt;/P&gt;&lt;P&gt;&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>Fri, 14 Jul 2017 09:50:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681285#M13973</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2017-07-14T09:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Time measurement</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681286#M13974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;Perhaps you could explain: - If I am reading the value in TPM2 count register - that contains the number of ticks since I enabled FreeCntr16 so is that not the most accurate measurement possible? If i only need a 16-bit result and no interrupt, Is there a method to start, stop and reset TPM2 directly so that I don't need FreeCntr16 at all? In real time the elapsed time will be between 0.5mS and 15mS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 08:28:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681286#M13974</guid>
      <dc:creator>juliancox</dc:creator>
      <dc:date>2017-07-17T08:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Time measurement</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681287#M13975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Julian&lt;/P&gt;&lt;P&gt;I finally found a board to test your project. here is my testing result&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/26638iE89E1A3B9A006824/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;P&gt;&lt;/P&gt;&lt;P&gt;here, I set breakpoint at FC161_Reset()&lt;/P&gt;&lt;P&gt;in&amp;nbsp; Variable window: Time is 0x223&lt;/P&gt;&lt;P&gt;in Registers window: TPM2CNT is 0x0227&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;these two values are different. This is because the program runs from previous line to FC161_Reset() takes a few clock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know what else you think abnormal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jennie Zhang&lt;/P&gt;&lt;P&gt;&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>Fri, 21 Jul 2017 09:23:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Time-measurement/m-p/681287#M13975</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2017-07-21T09:23:35Z</dc:date>
    </item>
  </channel>
</rss>

