<?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>Microseconds since start</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/120475/microseconds-since-start</link><description>I am using the nRF54L15 and SDK 2.9.1 in VSCode. 
 I need to know the microseconds since start throughout my code. 
 I created this function: 
 
 The problem is that CONFIG_SYS_CLOCK_TICKS_PER_SEC is defined as 31250. That means there are fewer ticks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Apr 2025 18:22:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/120475/microseconds-since-start" /><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/532908?ContentTypeID=1</link><pubDate>Thu, 24 Apr 2025 18:22:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e32a5298-8495-40a6-bc54-7dadf2154010</guid><dc:creator>Nick Ewalt</dc:creator><description>&lt;p&gt;&lt;span&gt;CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC should be 1000000, so rather than calling&amp;nbsp;nrfx_grtc_syscounter_get you can just call k_cycle_get_64.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/530873?ContentTypeID=1</link><pubDate>Mon, 07 Apr 2025 15:59:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce444989-ca95-4b74-a242-1b8c2d4fb9df</guid><dc:creator>Tony</dc:creator><description>&lt;p&gt;Thank you for the suggestions. I will try them out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/530872?ContentTypeID=1</link><pubDate>Mon, 07 Apr 2025 15:56:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbdd261f-0829-48f4-a5d4-571f751f40dc</guid><dc:creator>Emil Lenngren</dc:creator><description>&lt;p&gt;I guess you can just try it out? Otherwise you can probably use the&amp;nbsp;nrfx_grtc_syscounter_get method also which returns microseconds.&lt;/p&gt;
&lt;p&gt;CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC is the parameter that controls the actual hardware clock frequency.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/530867?ContentTypeID=1</link><pubDate>Mon, 07 Apr 2025 15:25:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23cd24d2-7b4f-4d41-abdd-423742f5497c</guid><dc:creator>Tony</dc:creator><description>&lt;p&gt;So I can just change the clock ticks per second and it will work? For some reason I thought that define value would be specific to the crystal and clock, board and processor and not something I could just change. I thought it would have to match....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/530865?ContentTypeID=1</link><pubDate>Mon, 07 Apr 2025 15:18:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29f834c8-10df-4fe1-a3a3-cf1f5a4307a6</guid><dc:creator>Emil Lenngren</dc:creator><description>&lt;p&gt;What I wrote was&amp;nbsp;regarding the hardware GRTC peripheral itself. And regarding the software, this is was the nRF Connect SDK already does when you query the current time, at least the last time I&amp;nbsp;examined the code. It could be that the k_uptime_ticks() converts the 1 MHz resolution timestamp from the GRTC to that defined &amp;quot;ticks per sec&amp;quot; divider though.&lt;/p&gt;
&lt;p&gt;This commit&amp;nbsp;&lt;a id="" href="https://github.com/nrfconnect/sdk-zephyr-testing/commit/175855e0d8032400d5544d47971dc654e1717ec4"&gt;https://github.com/nrfconnect/sdk-zephyr-testing/commit/175855e0d8032400d5544d47971dc654e1717ec4&lt;/a&gt;&amp;nbsp;sets the&amp;nbsp;&lt;span&gt;CONFIG_SYS_CLOCK_TICKS_PER_SEC to the completely arbitrary value 31250 with the motivation that it divides 1 million. I guess it should be possible to set it simply to 1000000 instead if you want better resolution. Not sure if there is a valid range on this configuration variable.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you want more details on the GRTC perihperal itself, you can see my findings here:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/116568/grtc-peripheral-not-always-emitting-scheduled-events"&gt;GRTC peripheral not always emitting scheduled events&lt;/a&gt;&amp;nbsp;. You can also read the GRTC docs in the data sheet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/530864?ContentTypeID=1</link><pubDate>Mon, 07 Apr 2025 15:06:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6d5f17d-98dc-4774-80e5-93b3154bebbe</guid><dc:creator>Tony</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/emil-lenngren"&gt;Emil Lenngren&lt;/a&gt;&amp;nbsp; Could you give more details about this please? Maybe a code example on how to implement it in my code? Power will be important, but I might be able to handle then while sleeping. While processing the RF signals I need good accuracy and it might be worth the power draw.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/530787?ContentTypeID=1</link><pubDate>Mon, 07 Apr 2025 11:09:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee380c4c-5075-4877-93e9-1568ed10e913</guid><dc:creator>Emil Lenngren</dc:creator><description>&lt;p&gt;I&amp;#39;m a bit surprised since the nRF54L platform only has GRTC, which is backed by a 32768 Hz clock, but that one cannot be queried directly&amp;nbsp;as opposed&amp;nbsp;to the RTC peripheral that is present in other nRF series. Instead, there is a 1 MHz clock waked up on demand, so the resolution is 1 tick per microsecond. If the high frequency clock that the GRTC uses when querying the current time is off, the solution implemented in nRF Connect is to trigger GRTC to start the high frequency clock, busy-loop the CPU up to 31 &amp;micro;s&amp;nbsp;so that the high frequency clock can synchronise with the low frequency clock, and then return the current &amp;micro;s at that point.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/530783?ContentTypeID=1</link><pubDate>Mon, 07 Apr 2025 10:51:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:687ede4f-9112-4816-8df6-6acf4e507f7a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;The system timer uses RTC which is low precision timer by design for lower power.&lt;/p&gt;
&lt;p&gt;If you want higher precision timer than like Fischer suggested, you need HFCLK based TIMER and you can then get a better accuracy on tick.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microseconds since start</title><link>https://devzone.nordicsemi.com/thread/530698?ContentTypeID=1</link><pubDate>Sat, 05 Apr 2025 15:53:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e684fbdf-b3b3-4fad-9f45-ca12f5d5417f</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;What do you need this time for? &lt;/p&gt;
&lt;p&gt;You can keep the HFXO running and use a TIMER peripherial, but that would require significantly more power than usual (in idle).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>