<?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_ticks_to_xdate in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/time-ticks-to-xdate/m-p/192766#M3881</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin&lt;/P&gt;&lt;P&gt;Thanks for reply&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrap the _time_ticks_to_xdate mqx function with this one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/*FUNCTION*------------------------------------------------------------** Function Name   : _time_ticks_to_xdateQueAnda* Returned Value  : boolean* Comments        : converts ticks into a date and time from*                   Jan.1 1970* Funciona teniendo en cuenta que hay 10000 HT por ms*END*------------------------------------------------------------------*/boolean _time_ticks_to_xdateQueAnda   (      /*  [IN]  pointer to tick structure  */      MQX_TICK_STRUCT_PTR  tick_ptr,      /*  [OUT]  pointer to a xdate structure  */      MQX_XDATE_STRUCT_PTR xdate_ptr   ){ /* Body */ boolean res; uint_32 temp; // dejar solo los milisegundos en la estructura de ticks temp = tick_ptr-&amp;gt;HW_TICKS % 10000;  // restar los usec de la estructura de ticks tick_ptr-&amp;gt;HW_TICKS -= temp;  // convertir a xdate res = _time_ticks_to_xdate(tick_ptr,xdate_ptr);  // volver a poner los usec en la estructura de tics tick_ptr-&amp;gt;HW_TICKS += temp;   // agregar usec, nsec y psec a xdate. xdate_ptr-&amp;gt;USEC = (uint_16)(temp / 10);  xdate_ptr-&amp;gt;NSEC = (uint_16)((temp % 10) * 100);  xdate_ptr-&amp;gt;PSEC = 0;  return res;} /* Endbody */&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I have 10000 HWTICKS per ms, so this function works for me.&lt;/P&gt;&lt;P&gt;I extract usec, nsec and psec from MQX_TICK_STRUCT, convert it to XDATE, then restore the extracted part and then complete the (now well converted) XDATE with usec, nsec and psec derived from the extracted part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:45:50 GMT</pubDate>
    <dc:creator>madifazio</dc:creator>
    <dc:date>2020-10-29T09:45:50Z</dc:date>
    <item>
      <title>_time_ticks_to_xdate</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/time-ticks-to-xdate/m-p/192764#M3879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some troubles with&amp;nbsp;_time_ticks_to_xdate function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code can be used as demostration&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;MQX_TICK_STRUCT stTime;MQX_XDATE_STRUCT xdate0;MQX_XDATE_STRUCT xdate1; xdate0.YEAR = 1970;xdate0.MONTH = 1;xdate0.MDAY = 1;xdate0.HOUR = 0;xdate0.MIN = 0;xdate0.SEC = 0;xdate0.MSEC = 1;xdate0.USEC = 800;xdate0.NSEC = 0;xdate0.PSEC = 0; _time_xdate_to_ticks(&amp;amp;xdate0,&amp;amp;stTime);_time_ticks_to_xdate(&amp;amp;stTime,&amp;amp;xdate1);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;After the conversion, xdate0 is diferent from xdate1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see that USEC &amp;gt; 500 (also NSEC &amp;gt; 500) result in &lt;SPAN&gt;adding one to&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;the milliseconds&lt;/SPAN&gt;&amp;nbsp;and random numbers in the minors fields (nsec, psec)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the numeric result of the code above&lt;/P&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;SPAN&gt;Resultados :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Campo &amp;nbsp;Xdate0 &amp;nbsp; &amp;nbsp; Xdate1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Año: &amp;nbsp; &amp;nbsp; &amp;nbsp; 1970 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1970&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mes: &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dia: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hor: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Min: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Seg: &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;msg: &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;usg: &amp;nbsp; &amp;nbsp; &amp;nbsp; 800 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6784&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;nsg: &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 35336&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;psg: &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 18052&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="line-height: 14px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;Any help would be apreciated&lt;/P&gt;&lt;P&gt;I suspect same isue in psp functions&lt;/P&gt;&lt;P&gt;_psp_ticks_to_milliseconds,&lt;/P&gt;&lt;P&gt;_psp_ticks_to_microseconds,&lt;/P&gt;&lt;P&gt;_psp_ticks_to_nanoseconds and&lt;/P&gt;&lt;P&gt;_psp_ticks_to_picoseconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:45:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/time-ticks-to-xdate/m-p/192764#M3879</guid>
      <dc:creator>madifazio</dc:creator>
      <dc:date>2020-10-29T09:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: _time_ticks_to_xdate</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/time-ticks-to-xdate/m-p/192765#M3880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi madifazio,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have not tried to run the program you included yet because i do not have MQX 3.6 intstalled.&lt;/P&gt;&lt;P&gt;I remember there was a bug in those functions&amp;nbsp; even in MQX 3.7 and they should&amp;nbsp; be fixed in MQX 3.8 .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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>Wed, 28 Dec 2011 21:51:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/time-ticks-to-xdate/m-p/192765#M3880</guid>
      <dc:creator>c0170</dc:creator>
      <dc:date>2011-12-28T21:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: _time_ticks_to_xdate</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/time-ticks-to-xdate/m-p/192766#M3881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martin&lt;/P&gt;&lt;P&gt;Thanks for reply&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrap the _time_ticks_to_xdate mqx function with this one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/*FUNCTION*------------------------------------------------------------** Function Name   : _time_ticks_to_xdateQueAnda* Returned Value  : boolean* Comments        : converts ticks into a date and time from*                   Jan.1 1970* Funciona teniendo en cuenta que hay 10000 HT por ms*END*------------------------------------------------------------------*/boolean _time_ticks_to_xdateQueAnda   (      /*  [IN]  pointer to tick structure  */      MQX_TICK_STRUCT_PTR  tick_ptr,      /*  [OUT]  pointer to a xdate structure  */      MQX_XDATE_STRUCT_PTR xdate_ptr   ){ /* Body */ boolean res; uint_32 temp; // dejar solo los milisegundos en la estructura de ticks temp = tick_ptr-&amp;gt;HW_TICKS % 10000;  // restar los usec de la estructura de ticks tick_ptr-&amp;gt;HW_TICKS -= temp;  // convertir a xdate res = _time_ticks_to_xdate(tick_ptr,xdate_ptr);  // volver a poner los usec en la estructura de tics tick_ptr-&amp;gt;HW_TICKS += temp;   // agregar usec, nsec y psec a xdate. xdate_ptr-&amp;gt;USEC = (uint_16)(temp / 10);  xdate_ptr-&amp;gt;NSEC = (uint_16)((temp % 10) * 100);  xdate_ptr-&amp;gt;PSEC = 0;  return res;} /* Endbody */&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I have 10000 HWTICKS per ms, so this function works for me.&lt;/P&gt;&lt;P&gt;I extract usec, nsec and psec from MQX_TICK_STRUCT, convert it to XDATE, then restore the extracted part and then complete the (now well converted) XDATE with usec, nsec and psec derived from the extracted part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:45:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/time-ticks-to-xdate/m-p/192766#M3881</guid>
      <dc:creator>madifazio</dc:creator>
      <dc:date>2020-10-29T09:45:50Z</dc:date>
    </item>
  </channel>
</rss>

