<?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>How to enable HFCLK in ZephyrOS (nRF Connect SDK 1.9)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86756/how-to-enable-hfclk-in-zephyros-nrf-connect-sdk-1-9</link><description>Hi, 
 I just want to learn if we can use high-freq clock to measure time in nanosecs precision. 
 SoC: nRF52840 
 SDK: nRF Connect SDK (v1.9) 
 I know that it was not possible 2 years ago but I just wonder whether it can be enabled in nRF Connect SDK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Apr 2022 13:31:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86756/how-to-enable-hfclk-in-zephyros-nrf-connect-sdk-1-9" /><item><title>RE: How to enable HFCLK in ZephyrOS (nRF Connect SDK 1.9)</title><link>https://devzone.nordicsemi.com/thread/364498?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 13:31:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18922b29-ff7d-41b1-8697-164f8adf56a3</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello, and thanks for your patience on this issue during the Easter Holiday.&lt;/p&gt;
&lt;p&gt;Unfortunately I don&amp;#39;t have many suggestions for how to get this to work. This is a hacky solution for something that shouldn&amp;#39;t really be possible. For questions about it, please ask on github.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable HFCLK in ZephyrOS (nRF Connect SDK 1.9)</title><link>https://devzone.nordicsemi.com/thread/362677?ContentTypeID=1</link><pubDate>Fri, 08 Apr 2022 21:41:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a1aa3bc-edef-4506-a8e6-7dcc0ecd9099</guid><dc:creator>ozanoner</dc:creator><description>&lt;p&gt;Thanks for the link,&amp;nbsp;&lt;span&gt;Elfving. It sounds very promising but unfortunately I couldn&amp;#39;t run my test app successfully. In my test app, I tried to add a simple k_timer and a periodic timeout handler in which led0 toggles.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The prj.conf file&amp;nbsp;sets the config&amp;nbsp;as in the link you&amp;#39;ve shared. (actually there is another one for nrf52840 here: &lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues/28469#issuecomment-704164283)"&gt;github.com/.../28469&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NRF_RTC_TIMER=n
CONFIG_CORTEX_M_SYSTICK=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=64000000
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000000&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And main.c:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;

static struct gpio_dt_spec led = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led0), gpios,
													 {0});

void my_timer_handler(struct k_timer *dummy)
{
	gpio_pin_toggle(led.port, led.pin);
}

K_TIMER_DEFINE(my_timer, my_timer_handler, NULL);

void main(void)
{
	int ret = 0;
	if (led.port &amp;amp;&amp;amp; !device_is_ready(led.port))
	{
		printk(&amp;quot;Error %d: LED device %s is not ready; ignoring it\n&amp;quot;,
			   ret, led.port-&amp;gt;name);
		led.port = NULL;
	}
	if (led.port)
	{
		ret = gpio_pin_configure_dt(&amp;amp;led, GPIO_OUTPUT);
		if (ret != 0)
		{
			printk(&amp;quot;Error %d: failed to configure LED device %s pin %d\n&amp;quot;,
				   ret, led.port-&amp;gt;name, led.pin);
			led.port = NULL;
		}
		else
		{
			printk(&amp;quot;Set up LED at %s pin %d\n&amp;quot;, led.port-&amp;gt;name, led.pin);
		}
	}

	k_timer_start(&amp;amp;my_timer, K_SECONDS(1), K_SECONDS(1));
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I see the led0 initialization is done on the serial output but I can&amp;#39;t see&amp;nbsp;led0 blinks.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When I comment out all prf.conf lines, which means when RTC is active as the clock source, the app starts to work as expected, ie led0 blinks. So apparently I&amp;#39;m missing something.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;In another application, I tested k_msleep(1) and this doesn&amp;#39;t work either. The app never passes the sleep line, which suggests the underlying&amp;nbsp;timer doesn&amp;#39;t work.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any&amp;nbsp;suggestion about&amp;nbsp;how I can correct the configuration? Or anything else that can help with that?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Many thanks,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Ozan&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable HFCLK in ZephyrOS (nRF Connect SDK 1.9)</title><link>https://devzone.nordicsemi.com/thread/362653?ContentTypeID=1</link><pubDate>Fri, 08 Apr 2022 16:07:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa12af22-74c2-4872-aa48-0d898222c113</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello Vedat,&lt;/p&gt;
&lt;p&gt;Unfortunately, I don&amp;#39;t think so. Though there was a bit of a &lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues/29977"&gt;hacky solution discussed here that might deserve a look.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/60049/configure-system-clock-faster-than-32768hz-in-ncs-zephyr/244400#244400"&gt;&lt;/a&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>