<?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>MQX Software Solutions中的主题 Re: How to solve MQX RTCS_time_get() problem?</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201917#M4615</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the code that MartinK just posted today in my thread, I bet it will help.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/300484"&gt;MQX 3.8 _time_get() -&amp;amp;gt;_time_to_date defect&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Sep 2012 19:13:41 GMT</pubDate>
    <dc:creator>timias</dc:creator>
    <dc:date>2012-09-26T19:13:41Z</dc:date>
    <item>
      <title>How to solve MQX RTCS_time_get() problem?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201916#M4614</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;I'm working on project that uses K53 and MQX 3.8.0 with CW C++. &lt;/P&gt;&lt;P&gt;I have done diff with the MQX 3.8.1 and looks like there is no changes to the code that seems to be problematic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problem I'm seeing is that for some reason RTCS_time_get() function ( _time_get_elapsed() ) can return values from the past. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Early on when I was trying to bring up our custom board couldn't get DHCP messages going out. Reason was that messages did seem to timeout prior they even went out. During that time I noticed that for some reason timedelta from the calculation below was sometimes negative.&lt;/P&gt;&lt;P&gt;From TCPIP_task()&lt;/P&gt;&lt;P&gt;timeafter = RTCS_time_get();&lt;/P&gt;&lt;P&gt;timedelta = (timeafter - timebefore);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which, I believe, made timedelta being huge positive number -&amp;gt; that made all the possible event timers to trigger.&amp;nbsp; And hence DHCP packet was never getting out since it timed out immediately. &lt;/P&gt;&lt;P&gt;To fix that I added code that would make timedelta being 0 in case timeafter was smaller than timebefore. That got us nicely forward during those crucial days of the board bringup. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I'm revisiting RTCS portion since we are seeing some extra RTCSERR_TCP_CONN_ABORTED errors. And when tracking down that one looks like same thing happened again in ticker.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; newtime = RTCS_time_get();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; elapsed = newtime - tcp_cfg-&amp;gt;lasttime; /* get elapsed msecs... */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; tcp_cfg-&amp;gt;lasttime = newtime;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;After reviewing the code from (PSP) ti_elapt.c I was just wondering what would be the best solution to my problem?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;Think it all comes down to underlying calls to &lt;/SPAN&gt;_time_get_elapsed_ticks() and PSP_NORMALIZE_TICKS() calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since our Debug output is using&amp;nbsp; _time_get_elapsed_ticks() from various threads with different priorities. &lt;/P&gt;&lt;P&gt;And it looks like we are getting very interesting time stamps.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2189.378:[3,T=0x10002]&lt;/P&gt;&lt;P&gt;2189.479:[3,T=0x1000b]&lt;/P&gt;&lt;P&gt;2190.505:[3,T=0x10006]&lt;/P&gt;&lt;P&gt;2191.026:[3,T=0x10006]&lt;/P&gt;&lt;P&gt;2191.141:[3,T=0x10006]&lt;/P&gt;&lt;P&gt;2191.015:[3,T=0x10006] &amp;lt;-- This would affect negative time. Note this is within one thread!!!&lt;/P&gt;&lt;P&gt;2191.093:[3,T=0x10006]&lt;/P&gt;&lt;P&gt;2191.164:[3,T=0x10006]&lt;/P&gt;&lt;P&gt;2191.235:[0,T=0x10006]&lt;/P&gt;&lt;P&gt;2191.082:[3,T=0x10003] &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kari&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 18:29:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201916#M4614</guid>
      <dc:creator>kaskasi</dc:creator>
      <dc:date>2012-09-26T18:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve MQX RTCS_time_get() problem?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201917#M4615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the code that MartinK just posted today in my thread, I bet it will help.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/thread/300484"&gt;MQX 3.8 _time_get() -&amp;amp;gt;_time_to_date defect&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 19:13:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201917#M4615</guid>
      <dc:creator>timias</dc:creator>
      <dc:date>2012-09-26T19:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve MQX RTCS_time_get() problem?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201918#M4616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Improved. &lt;/P&gt;&lt;P&gt;I don't see Socket error, but debug messages still show the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2869.468:[3,T=0x10003] &lt;/P&gt;&lt;P&gt;2869.410:[0,T=0x1000b] &amp;lt;-- Still there&lt;/P&gt;&lt;P&gt;2869.503:[0,T=0x1000b] &lt;/P&gt;&lt;P&gt;2869.620:[3,T=0x1000b] &lt;/P&gt;&lt;P&gt;2869.535:[3,T=0x1000b] &amp;lt;-- Still there&lt;/P&gt;&lt;P&gt;2869.441:[3,T=0x1000b] &amp;lt;-- Still there&lt;/P&gt;&lt;P&gt;2869.537:[3,T=0x10002] &lt;/P&gt;&lt;P&gt;2869.476:[3,T=0x10002] &amp;lt;-- Still there&lt;/P&gt;&lt;P&gt;2869.563:[3,T=0x10002] &lt;/P&gt;&lt;P&gt;2869.664:[3,T=0x1000b] &lt;/P&gt;&lt;P&gt;2870.984:[3,T=0x10006] &lt;/P&gt;&lt;P&gt;2871.505:[3,T=0x10006] &lt;/P&gt;&lt;P&gt;2871.618:[3,T=0x10006] &lt;/P&gt;&lt;P&gt;2871.491:[3,T=0x10006] &amp;lt;-- Still there&lt;/P&gt;&lt;P&gt;2871.569:[3,T=0x10006] &lt;/P&gt;&lt;P&gt;2871.641:[3,T=0x10006] &lt;/P&gt;&lt;P&gt;2871.711:[0,T=0x10006] &lt;/P&gt;&lt;P&gt;2871.557:[3,T=0x10003] &amp;lt;-- Still there&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Kari Sipinen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 19:59:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201918#M4616</guid>
      <dc:creator>kaskasi</dc:creator>
      <dc:date>2012-09-26T19:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve MQX RTCS_time_get() problem?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201919#M4617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kari,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;glad it improved, but problem still persists somewhere. Can you debug and identify the problem why you are getting wrong timestamps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not know much about your application , but what if you test to put in the fix I posted, in the beginning disable_int and enable_int in the end of the function. Let me know what happens.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MartinK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 09:25:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201919#M4617</guid>
      <dc:creator>c0170</dc:creator>
      <dc:date>2012-09-27T09:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve MQX RTCS_time_get() problem?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201920#M4618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will try later today.&lt;/P&gt;&lt;P&gt;Meanwhile can you review MQX code in time_get_elapsed_ticks() function ti_elapt.c. It calls _psp_normalize_ticks() from psp_tinm.c. That code seems to decrement HW_TICKS[0] while interrupts are enabled. Without knowing history of CR 1082 that looks somewhat suspicious.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Later,&lt;/P&gt;&lt;P&gt;Kari&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 11:43:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201920#M4618</guid>
      <dc:creator>kaskasi</dc:creator>
      <dc:date>2012-09-27T11:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve MQX RTCS_time_get() problem?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201921#M4619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the latest.&lt;/P&gt;&lt;P&gt;After reviewing MQX code (maybe more than I ever wanted :smileyconfused: ) I have done following. &lt;/P&gt;&lt;P&gt;Left Martin's changes in _pspticks_to_time() as is (not protected with disa ena interrupts). &lt;/P&gt;&lt;P&gt;Did comment out code from the _time_get_elapsed_ticks() function in ti_elapt.c that was marked with comment /* Start CR 1082 */ and /* End CR 1082*/ &lt;/P&gt;&lt;P&gt;Obviously added _INT_ENABLE() (which I first forgot).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reason for change: Looks like in our application _time_get_elapsed_ticks() function gets called way too many times which affected PSP_NORMALIZE_TICKS be called all the time. In my opinion that should be called only by the _time_notify_kernel() in ti_krnl.c. Which pretty much is time keeper for whole system. _time_notify_kernel() also calls _timer_isr() which calls _time_get_elapsed_ticks() etc. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So for now in our application this seems to work much more reliably. Timestamps are now aligned. Interrupts are disabled less, which suddenly seems to make things work better. Obviously this is just day after I tried these changes so there might be some huge unwanted features around the corner... We shall see!!! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Later,&lt;/P&gt;&lt;P&gt;Kari&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 14:29:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201921#M4619</guid>
      <dc:creator>kaskasi</dc:creator>
      <dc:date>2012-09-28T14:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve MQX RTCS_time_get() problem?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201922#M4620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After debugging timing problem, which I think was unrelated one. Decided to go with "safer" implementation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Created _time_get_elapsed_simple() that calls _time_get_elapsed_tics_simple() which has changed mentioned in my previous post.&lt;/P&gt;&lt;P&gt;Changed our application to call _time_get_elapsed_simple() to get timestamp for the debug messages. Timestamps seem to be correct. And so far I have not seen problems with the RTCS_time_get().&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Oct 2012 15:47:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-solve-MQX-RTCS-time-get-problem/m-p/201922#M4620</guid>
      <dc:creator>kaskasi</dc:creator>
      <dc:date>2012-10-01T15:47:15Z</dc:date>
    </item>
  </channel>
</rss>

