<?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>Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/101860/get-current-time-with-kernel-timer</link><description>Hello, 
 I like to get the current time with a kernel_timer. So I use the function k_uptime_get(). 
 However,with each call the timer starts again from the beginning (from 0).Is there a method how i can bypass that it starts again from 0.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Jul 2023 08:45:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/101860/get-current-time-with-kernel-timer" /><item><title>RE: Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/thread/436924?ContentTypeID=1</link><pubDate>Tue, 18 Jul 2023 08:45:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de3e60fe-70c8-43f9-96ff-92f856623582</guid><dc:creator>Tal.</dc:creator><description>&lt;p&gt;I just call the function k_uptime_get one time in my code. Thats why I get the same time, when I print the time&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/thread/436793?ContentTypeID=1</link><pubDate>Mon, 17 Jul 2023 14:19:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:378ea7c9-de9c-4a1d-866a-732f5c0abeb0</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Good to hear that you were able to solve it Tal!&lt;/p&gt;
&lt;p&gt;Are you able to share how you solved your problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/thread/436787?ContentTypeID=1</link><pubDate>Mon, 17 Jul 2023 14:09:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99348696-02c4-4170-b147-76ad49403f07</guid><dc:creator>Tal.</dc:creator><description>&lt;p&gt;Thank you. I find the problem and solve it.&lt;/p&gt;
&lt;p&gt;Thanks anyway&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/thread/436640?ContentTypeID=1</link><pubDate>Mon, 17 Jul 2023 07:00:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90e585cb-e674-433f-8e5d-bd75c2f0e19b</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi Tal and Louis,&lt;/p&gt;
&lt;p&gt;Thank you a lot for the answers Louis, we appreciate that the community is helping out!&lt;/p&gt;
&lt;p&gt;Tal, DevZone is a public forum as you know, and not all that answers are Nordic Employees.&lt;br /&gt;Louis is not a Nordic employee, so if I make the case private, he can no longer see the case.&lt;/p&gt;
&lt;p&gt;Instead of making the case private, I suggest that you take one of our samples, for example zephyr/samples/hello_world and re-create the issue in this&amp;nbsp; sample.&lt;br /&gt;This has two advantages:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You will be able to share code in a public case.&lt;/li&gt;
&lt;li&gt;Creating a minimal sample is a good way to narrow down what went wrong&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you do so, I will try the sample and see if I can figure out what is wrong.&lt;br /&gt;And if Louis want to, he can have a look as well.&lt;/p&gt;
&lt;p&gt;Does that work for you?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellevik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/thread/436555?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2023 17:03:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:260bb914-26d0-497a-a5de-ec37ccf9d38b</guid><dc:creator>Tal.</dc:creator><description>&lt;p&gt;If you turn the ticket&amp;nbsp; to privat, it would be better and than I can post a part of my code.&lt;/p&gt;
&lt;p&gt;Is it possible?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/thread/436553?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2023 16:21:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94317924-1749-48bf-b41e-1a76c31f7c50</guid><dc:creator>nordicator_prim3</dc:creator><description>&lt;p&gt;It should not restart because of exiting the idle thread. That is interesting. Are you able to post your code? Are you using any power savings modes or something?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/thread/436410?ContentTypeID=1</link><pubDate>Fri, 14 Jul 2023 08:36:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1299843-1ddd-408b-a8c4-eb0be06d1c13</guid><dc:creator>Tal.</dc:creator><description>&lt;p&gt;thank you for your answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;enclosed you can see my output. As you can see I have output currenttime. However, with both the system restarts, so that the same number is printed out. After &amp;quot;Tasks_sleep_mode&amp;quot; my system ist entering the IDLE Thread and is waking up with an interrupt. In my Interrupt i am printing the current time. Does the timer starts again after getting out of the IDLE Thread?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1689323805161v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get Current Time with kernel Timer</title><link>https://devzone.nordicsemi.com/thread/436343?ContentTypeID=1</link><pubDate>Thu, 13 Jul 2023 21:14:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b55548aa-c9aa-4488-86ce-fb55e846e56e</guid><dc:creator>nordicator_prim3</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;k_uptime_get() does not reset when you use it. Is it saying &amp;quot;0&amp;quot; every time? I&amp;#39;m guessing youre looking at it with a printk or LOG_XXX function. If so it&amp;#39;s probably just not printing the 64 bit number correctly. For instance,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;while(1)
{
    printk(&amp;quot;%d\n&amp;quot;, k_uptime_get());
    k_msleep(1000);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Would print &amp;quot;0&amp;quot; every time because the %d is not expecting a 64 bit number. It&amp;#39;s only printing the upper 32 bits which is 0 until 4,294,967,295 milliseconds have elapsed.&lt;/p&gt;
&lt;p&gt;If you do this instead:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;while(1)
{
    printk(&amp;quot;%&amp;quot;PRIu64&amp;quot;\n&amp;quot;, k_uptime_get());
    k_msleep(1000);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then it will print the correct values. Or you could use this if you dont need all 64 bits:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;while(1)
{
    printk(&amp;quot;%d\n&amp;quot;, k_uptime_get_32());
    k_msleep(1000);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>