<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Milliseconds from nrf calendar example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83259/milliseconds-from-nrf-calendar-example</link><description>can i generate milliseconds using nrf calendar example?? that is only printing up to seconds I want milliseconds too?? 
 I am using nrf52840 and SDK 17.02. 
 waiting for your precious replies. thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 Jan 2022 12:10:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83259/milliseconds-from-nrf-calendar-example" /><item><title>RE: Milliseconds from nrf calendar example</title><link>https://devzone.nordicsemi.com/thread/345650?ContentTypeID=1</link><pubDate>Mon, 03 Jan 2022 12:10:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a245612-c756-4d3f-af83-1cae59919219</guid><dc:creator>Sami Ul Haq</dc:creator><description>&lt;p&gt;Thank you for your precious reply, i did a lot of changes to the&amp;nbsp;&lt;strong&gt;char *nrf_cal_get_time_string(bool calibrated)&amp;nbsp;&lt;/strong&gt;function. Also i change the &lt;strong&gt;CAL_RTC-&amp;gt;PRESCALER =&lt;/strong&gt; 0 and the&amp;nbsp; corresponding&amp;nbsp;&lt;strong&gt;(CAL_RTC-&amp;gt;COUNTER /32.768)&lt;/strong&gt;; but the problem is that&amp;nbsp;&lt;strong&gt;struct tm&amp;nbsp;&lt;/strong&gt;does not has the tag for milliseconds like Hour, minutes etc. I use the below logic, this logic add another tag to YY:mm:HH:SS.&amp;nbsp; But it does not calculate the milliseconds.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;char *nrf_cal_get_time_string(bool calibrated)&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; uint64_t milli;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; uint32_t sec;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;char currentTime[84] = &amp;quot;&amp;quot;;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; time_t return_time;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; static char cal_string[80];&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; return_time = m_time + (CAL_RTC-&amp;gt;COUNTER) /32.768 ;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; m_tm_return_time = *localtime(&amp;amp;return_time);&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; sec=m_tm_return_time.tm_sec;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; milli=round(m_tm_return_time.tm_sec*1000);&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; strftime(cal_string, 80, &amp;quot;%Y%m%d %H:%M:%S%:&amp;quot;,&amp;amp;m_tm_return_time);&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt; sprintf(currentTime, &amp;quot;%s:%d&amp;quot;, cal_string, milli);&lt;/strong&gt;&lt;br /&gt;printf(&amp;quot;calibrated time: \t%s\r\n&amp;quot;, currentTime);&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;return cal_string;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;the above logic gives the following result&lt;/p&gt;
&lt;p&gt;calibrated time: 19700101 00:01:22:536872881&lt;br /&gt;calibrated time: 19700101 00:01:23:536872881&lt;br /&gt;calibrated time: 19700101 00:01:24:536872881&lt;br /&gt;calibrated time: 19700101 00:01:25:536872881&lt;br /&gt;calibrated time: 19700101 00:01:26:536872881&lt;br /&gt;calibrated time: 19700101 00:01:27:536872881&lt;br /&gt;calibrated time: 19700101 00:01:28:536872881&lt;br /&gt;calibrated time: 19700101 00:01:29:536872881&lt;br /&gt;calibrated time: 19700101 00:01:30:536872881&lt;br /&gt;calibrated time: 19700101 00:01:31:536872881&lt;br /&gt;calibrated time: 19700101 00:01:32:536872881&lt;br /&gt;calibrated time: 19700101 00:01:33:536872881&lt;br /&gt;calibrated time: 19700101 00:01:34:536872881&lt;br /&gt;calibrated time: 19700101 00:01:35:536872881&lt;br /&gt;calibrated time: 19700101 00:01:36:536872881&lt;br /&gt;calibrated time: 19700101 00:01:37:536872881&lt;br /&gt;calibrated time: 19700101 00:01:38:536872881&lt;br /&gt;calibrated time: 19700101 00:01:39:536872881&lt;br /&gt;calibrated time: 19700101 00:01:40:536872881&lt;br /&gt;calibrated time: 19700101 00:01:41:536872881&lt;br /&gt;calibrated time: 19700101 00:01:42:536872881&lt;br /&gt;calibrated time: 19700101 00:01:43:536872881&lt;br /&gt;Time updates off&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Milliseconds from nrf calendar example</title><link>https://devzone.nordicsemi.com/thread/345615?ContentTypeID=1</link><pubDate>Mon, 03 Jan 2022 10:14:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d8b4392-b7f6-4253-a58b-91fb1423763a</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;See here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/37762/nrf_calendar_example"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/37762/nrf_calendar_example&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>