<?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のトピック_time_diff_milliseconds returns 0</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/time-diff-milliseconds-returns-0/m-p/459069#M15429</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #3a0699;"&gt;My BSP is set to 5msec with 200Hz alarm frequency.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3a0699; font-family: 'trebuchet ms', geneva;"&gt;I am trying to use this tiny piece of code to see if 1msec has passed or not (Is there any other way to attain this without re-compiling BSP with 1000Hz) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;_time_get_ticks(&amp;amp;ticker_old);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;while(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _time_get_ticks(&amp;amp;ticker_new);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int32_t timediff_msec = _time_diff_milliseconds(&amp;amp;ticker_new,&amp;amp;ticker_old, &amp;amp;overflow);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(timediff_msec &amp;gt;=1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #3a0699;"&gt;BUT "_time_diff_milliseconds" always returns 0...What am I doing wrong here ?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Nov 2015 16:56:50 GMT</pubDate>
    <dc:creator>nitinharish</dc:creator>
    <dc:date>2015-11-05T16:56:50Z</dc:date>
    <item>
      <title>_time_diff_milliseconds returns 0</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/time-diff-milliseconds-returns-0/m-p/459069#M15429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #3a0699;"&gt;My BSP is set to 5msec with 200Hz alarm frequency.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3a0699; font-family: 'trebuchet ms', geneva;"&gt;I am trying to use this tiny piece of code to see if 1msec has passed or not (Is there any other way to attain this without re-compiling BSP with 1000Hz) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;_time_get_ticks(&amp;amp;ticker_old);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;while(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _time_get_ticks(&amp;amp;ticker_new);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int32_t timediff_msec = _time_diff_milliseconds(&amp;amp;ticker_new,&amp;amp;ticker_old, &amp;amp;overflow);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(timediff_msec &amp;gt;=1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #303030;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'trebuchet ms', geneva; color: #3a0699;"&gt;BUT "_time_diff_milliseconds" always returns 0...What am I doing wrong here ?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 16:56:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/time-diff-milliseconds-returns-0/m-p/459069#M15429</guid>
      <dc:creator>nitinharish</dc:creator>
      <dc:date>2015-11-05T16:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: _time_diff_milliseconds returns 0</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/time-diff-milliseconds-returns-0/m-p/459070#M15430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nitin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am sorry this is not possible to achieve with the function you try to use. In this case you need a hardware timer, you may find the following document interesting.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/docs/DOC-104385"&gt;Using the MQX timers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the reason why you are not able to use _time_diff_milliseconds is the same why it is not possible to have less that 5 ms delays. Please find the explanation below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;The systick is the smallest unit of time in &lt;STRONG&gt;MQX&lt;/STRONG&gt;, it is used by MQX as the system clock and is the base of any delay or timer function.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;Systick is defined by default as follows: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;#define BSP_ALARM_FREQUENCY (200). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;This macro defines the number of ticks per second, default is 200 ticks per second, this means each tick is 5 milliseconds, therefore, the smallest delay you can have in your MQX application is 5 milliseconds. All values that are not multiple of 5 millisecond will be truncated. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;In order to change the tick period you must calculate the value of #define BSP_ALARM_FREQUENCY ( ) to met your application's requirements. You can redeclare this macro in user_config.h. After editing this macro you must recompile BSP and PSP.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;Delays are calculated in the following way: &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;# of ticks = # of miliseconds requested x ( # of ticks per second / 1000 miliseconds) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;if BSP_ALARM_FREQUENCY is set as default (100) and you request a 55ms delay you will have: 55ms x (100 ticks / 1000ms) = 5.5 ticks This value will be truncated to 5 ticks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: .05in; text-indent: -.35pt;"&gt;&lt;SPAN style="font-size: 15.0pt; font-family: 'Calibri','sans-serif'; color: black;"&gt;Please note that modifying the systick may impact the kernel performance because the dispatcher will be called each time the systick expires.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-top: 3.6pt; margin-left: .38in; text-indent: -.38in; text-align: left;"&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Carlos&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>Thu, 05 Nov 2015 21:16:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/time-diff-milliseconds-returns-0/m-p/459070#M15430</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2015-11-05T21:16:36Z</dc:date>
    </item>
  </channel>
</rss>

