<?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>auto update of epoch time</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83379/auto-update-of-epoch-time</link><description>Hi all, 
 I&amp;#39;am sending epoch time from nrf_connect(mobile) to nrf52840dk only once, 
 then i need to update epoch time continuosly with nanosecond frequency 
 how can i do it 
 
 Regards 
 Tushar</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 11 Jan 2022 12:35:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83379/auto-update-of-epoch-time" /><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/347156?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 12:35:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3363f346-8a77-4d26-990e-635553a80ae1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;It is not possible. The frequency of the RTC is 32.768 kHz.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/347144?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 12:02:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39133bf2-f81d-4741-a51b-c4e107e14b80</guid><dc:creator>Tushar_V</dc:creator><description>&lt;p&gt;Hi Einar Thorsrud,&lt;/p&gt;
&lt;p&gt;In RTC which api can i use to get the value in microsecond&amp;nbsp;&lt;/p&gt;
&lt;p&gt;can u please tell me&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Tushar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/347134?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 11:50:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a00a2c77-b753-4f65-be3d-e9434e5b8b70</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Tushar,&lt;/p&gt;
&lt;p&gt;There is no timer with that resolution in Zephyr (you could get CPU cycles, but that will most likely not work as I assume you don&amp;#39;t intend to let the CPU run always, wasting power(?)).&lt;/p&gt;
&lt;p&gt;Moreover, there is no low power clock source that will give you that resolution, so if you want that you will have to use a TIMER peripheral. You would need to handle wrap arounds though (perhaps simplest by using a 64 bit offset that you update whenever it wraps around), and normally when you read the time take the current timer value + the accumulated offset (+ whatever you got from syncing with the phone).&lt;/p&gt;
&lt;p&gt;Note that this can never be low power, and there is physically no way to get better resolution than maximum 32.768 kHz with low power, as that is the frequency of the low power oscillator on the hardware. If you need low power (this is a key question!), then the only option to also give you better time resolution is to use an external RTC that can give a compromise between resolution, accuracy and power consumption that fits you requirements.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/347129?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 11:33:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2946fc79-433a-43b0-baa1-486322a6ff96</guid><dc:creator>Tushar_V</dc:creator><description>&lt;p&gt;Hi Einar Thorsrud,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am using k_uptime_get() which is giving me values in millisecond in nrf_connect_sdk&amp;nbsp; zephyr&lt;/p&gt;
&lt;p&gt;is there any api which gives microsecond&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Tushar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/346654?ContentTypeID=1</link><pubDate>Fri, 07 Jan 2022 10:28:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:071c2af4-9e8f-49c4-889b-5eba39c86bfa</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Tushar,&lt;/p&gt;
&lt;p&gt;That is up to you. The only thing you get from the SDK is time as ticks of a counter of some sort (there are many different options here, but it all comes down to the same), and you must relate that to the real time you got from the phone.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/346630?ContentTypeID=1</link><pubDate>Fri, 07 Jan 2022 09:16:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81c52683-8ceb-4edb-ae6e-9508accd8ab5</guid><dc:creator>Tushar_V</dc:creator><description>&lt;p&gt;Hi Einar Thorsrud,&lt;/p&gt;
&lt;p&gt;timeutil_timegm() and timeutil_timegm64() converts human readable to epoch time but i am passing value from mobile to nrf52840dk is epoch value, so i want an api which gives me epoch value of the current timezone&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Tushar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/346609?ContentTypeID=1</link><pubDate>Fri, 07 Jan 2022 08:06:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c6e5c28-6670-4426-8bd6-0e0b37d3fa9b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Tushar,&lt;/p&gt;
&lt;p&gt;I was too quick typing my answer previously. The&amp;nbsp;timeutil_timegm() or&amp;nbsp;timeutil_timegm64() is what you want. This gives you the current &amp;quot;time&amp;quot; and you offset it with the value you got from the same function when you got the actual time from the phone. (You won&amp;#39;t get&amp;nbsp;nanosecond resolution in any case, though.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/346595?ContentTypeID=1</link><pubDate>Fri, 07 Jan 2022 06:47:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19c1f3fc-bca5-4b50-a99e-0497c06d6b2c</guid><dc:creator>Tushar_V</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;code class="sig-name descname"&gt;&lt;span class="pre"&gt;timeutil_sync_state_update&lt;/span&gt;&lt;/code&gt;() i have used this api can u please tell me how to give input to this api&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Tushar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/346417?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 10:37:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79f764cf-7fee-4c0d-9d7d-60c32d5e3b3b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Tushar,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Are you using nRF5 SDK or nRF Connect SDK?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If using nRF5 SDK get the local time at the same time as you get the time from the phone, and calculate the offset. Use that offset subsequently.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If using the nRF Connect DK you have all this done for you, so use the available time utilities I linked to in my previous post (for instance, use&amp;nbsp;timeutil_sync_state_update() when you get the time from the phone).&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/346408?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 10:20:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52d8004d-fd0f-466f-becd-fbe67776a088</guid><dc:creator>Tushar_V</dc:creator><description>&lt;p&gt;Hi Einar Thorsrud,&lt;/p&gt;
&lt;p&gt;i want to give an epoch time for example 1641464227&amp;nbsp; from my mobile to nrf52840dk &lt;/p&gt;
&lt;p&gt;then i want the epoch time to increment continuously with time sync&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Tushar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: auto update of epoch time</title><link>https://devzone.nordicsemi.com/thread/346403?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 10:13:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5d05ec3-05a4-4d55-aab0-d468dee42d7f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Tushar,&lt;/p&gt;
&lt;p&gt;Which exact resolution do you need? If you really need close to nanosecond resolution, then you will have to use a timer which is based on the HF clock. This is only 16 MHz though, and there are no higher frequency clocks available. Also, this will force the HF clock always on, so your device will not be low power.&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t need as high resolution and needs the device to be low power, then it makes more sense to use an RTC based approach. The RTC is 32.768 kHz and the accuracy will be identical to the accuracy of the 32.768 kHz crystal you use on your board.&lt;/p&gt;
&lt;p&gt;In the latter case, if using the nRF5 SDK, the simplest way to do this is to use the app_timer library which is almost always used, and change it slightly so that the you can use the&amp;nbsp;get_now() function from outside (see &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/67006/how-to-generate-unix-epoch-time-stamp-using-nrf52840/274505#274505"&gt;this post&lt;/a&gt;). This will then give you an always increasing 64 bit timer value. With this, just compare that with the time you got when you synced with a mobile phone, and you will effectively have the epoch time. If using nRF Connect SDK, you already have &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/zephyr/reference/misc/timeutil.html"&gt;support for epoch time&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>