<?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 do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105569/how-do-i-turn-off-the-clock-for-rf-clock_control_nrf_subsys_hf</link><description>Hi, 
 
 On nRF52811 I use simple ESB radio for TX. Before TX I turn Clock for radio on like in the example: 
 
 
 After TX is done, I want to turn this clock OFF. I assume at least that I have to do it - because after the TX I want to go to sleep mode</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Dec 2023 14:04:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105569/how-do-i-turn-off-the-clock-for-rf-clock_control_nrf_subsys_hf" /><item><title>RE: How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/thread/461449?ContentTypeID=1</link><pubDate>Thu, 21 Dec 2023 14:04:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95ddf9f8-2e87-4c44-a735-3ab60886a0d8</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Did you try and test like the code&amp;nbsp;provided?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/thread/459765?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 18:00:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:966b0af1-3dd8-45a1-844f-7988d70ef5e3</guid><dc:creator>witc</dc:creator><description>&lt;p&gt;Thank you very very much, your code saved mea nd it works, I used code bellow, &lt;span&gt;But I would be interested in why the codes below didn&amp;#39;t work the same way.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;For Turning Off I used:&lt;/strong&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;NRF_CLOCK-&amp;gt;TASKS_HFCLKSTOP = 1;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;while ((NRF_CLOCK-&amp;gt;HFCLKSTAT &amp;amp; (1&amp;lt;&amp;lt;0))); &amp;nbsp;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;or&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;while(clock_control_off(dev, CLOCK_CONTROL_NRF_SUBSYS_HF) !=0);&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;And for On I used:&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;or&amp;nbsp;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; if (!clk_mgr) {&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return -ENXIO;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; }&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; sys_notify_init_spinwait(&amp;amp;clk_cli.notify);&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; err = onoff_request(clk_mgr, &amp;amp;clk_cli);&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; if (err &amp;lt; 0) {&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return err;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; }&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; do {&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; err = sys_notify_fetch_result(&amp;amp;clk_cli.notify, &amp;amp;res);&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!err &amp;amp;&amp;amp; res) {&lt;/em&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return res;&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/em&gt;&lt;/div&gt;
&lt;div&gt;&lt;em&gt;&amp;nbsp; &amp;nbsp; } while (err);&lt;/em&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/thread/459763?ContentTypeID=1</link><pubDate>Mon, 11 Dec 2023 17:40:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce4c73bb-0c6a-4eda-b447-ea1ddaf976fa</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the delayed response.&lt;/p&gt;
&lt;p&gt;Is there any update at your end?&lt;/p&gt;
&lt;p&gt;What kind of error / issues you got after using that API?&lt;/p&gt;
&lt;p&gt;I started with blinky sample, and then incorporated the header files and then called those functions to enable and disable the HFClock.&lt;/p&gt;
&lt;p&gt;I am repeating in a loop with 10 seconds for each&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1702316191195v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;In the power profiler, I can see the average current consumption difference&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1702316275014v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;When the HFClock is ON, average current consumption is ~185uA higher than the case when HFClock is OFF.&lt;/p&gt;
&lt;p&gt;This is how I have defined the sys and dev:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define sys CLOCK_CONTROL_NRF_SUBSYS_HF
static const struct device *const dev = DEVICE_DT_GET_ONE(nordic_nrf_clock);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;/BR, Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/thread/459290?ContentTypeID=1</link><pubDate>Thu, 07 Dec 2023 08:24:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:187eee83-21f2-46dc-b61f-77fb49c49b41</guid><dc:creator>witc</dc:creator><description>&lt;p&gt;Could anyone help please?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/thread/458241?ContentTypeID=1</link><pubDate>Thu, 30 Nov 2023 09:22:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b275ce5-aa41-41ee-9e54-543c8726441c</guid><dc:creator>witc</dc:creator><description>&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;I have tried but still can&amp;#39;t succeed: I am exactly following the ESB TX example. All I need is to turn off the HFCLOCK after each transmission (believing that I reduce consumption to a minimum). I use Zephyr and my goal is to periodically transmit one packet every second. I have a SW timer that is triggered after each TX done and transmits again in a second, so I want Zephyr to put the processor to sleep as deeply as possible to reduce consumption between each transmission. I tried 2 ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Using registers:&lt;br /&gt; &lt;em&gt;NRF_CLOCK-&amp;gt;TASKS_HFCLKSTOP = 1;&lt;/em&gt;&lt;br /&gt;&lt;em&gt; while ((NRF_CLOCK-&amp;gt;HFCLKSTAT &amp;amp; (1&amp;lt;&amp;lt;16)));&lt;/em&gt;&lt;br /&gt; But when I do this, HFCLKSTAT only changes the source from Xtall to RC, but STATE is still running, does that mean that the internal HFCLK RC is needed as a source for CPU operation and cannot be turned off, but is it turned off by zephyr upon entering sleep?&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;I called &lt;em&gt;while(clock_control_off(dev, CLOCK_CONTROL_NRF_SUBSYS_HF) !=0);&lt;/em&gt; But this loop gets stuck and never ends - the clock is still running on Xtall.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;If I disable the HCLK through the registers after TX_Done, it seems that Zephyr falls asleep and is no longer awakened by the software timer which is supposed to send the next packet. I don&amp;#39;t understand this. However, if I connect via RTT to CPU what is happening in the processor, everything works fine.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Thank you.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/thread/455520?ContentTypeID=1</link><pubDate>Tue, 14 Nov 2023 12:59:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fc41a3e-0bf9-409a-83cd-2b4307a15a48</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Yes, you can use that API.&lt;/p&gt;
&lt;p&gt;From the&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/drivers/clock_control.h&amp;gt;&lt;/pre&gt;&amp;nbsp;we have&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;static int clock_control_on(const struct device *dev, clock_control_subsys_t sys);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;where the device is the clock-peripheral and the clock-control-subsystem is the HFCLock subsystem.&lt;/p&gt;
&lt;p&gt;(For details, please look at clock_control.h, nrf_clock_control.h, and clock_control_nrf.c).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We can get the device and subsystem as:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define sys ((clock_control_subsys_t)CLOCK_CONTROL_NRF_TYPE_HFCLK)

static const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(clock));
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;/BR, Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/thread/455480?ContentTypeID=1</link><pubDate>Tue, 14 Nov 2023 09:50:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fad6b19c-2119-45f5-9ccd-b26ae2d29bb3</guid><dc:creator>witc</dc:creator><description>&lt;p&gt;Hi Naeem,&lt;/p&gt;
&lt;p&gt;Thank you for detailed answer!. Your code solved my problem. Anyway I would prefer to use Zephyr API as you wrote. I went to zephyr API and found &lt;a href="https://docs.zephyrproject.org/apidoc/latest/group__clock__control__interface.html#gadbebc1c12937be561b761ef4a3b7d8a5"&gt;this&lt;/a&gt;. Could it be he function what I am looking for to STOP HFLCK?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If yes, the&amp;nbsp;input params *&lt;a class="el" href="https://docs.zephyrproject.org/apidoc/latest/structdevice.html"&gt;device&lt;/a&gt;&amp;nbsp; and &lt;em&gt;sys&lt;/em&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;- where I can get it? In nrf52840dk_nrf52811.dts I could not find nothing about clk.&lt;br /&gt;&lt;br /&gt;Maybe rather than a solution, I would be interested in how to proceed so that I can use the API myself next time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF</title><link>https://devzone.nordicsemi.com/thread/455406?ContentTypeID=1</link><pubDate>Mon, 13 Nov 2023 19:43:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d489294d-1d13-425c-97d5-508515b73e7b</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Thank you for contacting DevZone at NordicSemi.&lt;/p&gt;
&lt;p&gt;To go to the Datasheet / Product Specification of any nordic SoC, please go to &lt;a href="https://infocenter.nordicsemi.com/index.jsp"&gt;InfoCenter &lt;/a&gt;or the &lt;a href="https://docs.nordicsemi.com/"&gt;TechDocs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You will find detailed chapters on peripherals and their registers.&lt;/p&gt;
&lt;p&gt;We also provide HAL and Driver files for nordic peripherals. We have a collection of drivers and HAL called &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfx/drivers/clock/hal.html"&gt;NRFX&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You will find all these within the SDK and on the Github.&lt;/p&gt;
&lt;p&gt;As the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/index.html"&gt;Nordic&amp;#39;s Connect SDK (NCS)&lt;/a&gt; is Zephyr RTOS based sdk, it is preferred to use Zephyr APIs and libraries.&lt;/p&gt;
&lt;p&gt;Also, we refer our customers to base their designs or start with the samples provided in the NCS (which contains both the Zephyr samples and Nordic specific samples).&lt;/p&gt;
&lt;p&gt;I am not sure how relevant to you it will be, but you can start by looking at &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/esb/esb_ptx/README.html#esb-ptx"&gt;ESB Transmitter sample&lt;/a&gt;, and then modify the code as per your requirements.&lt;/p&gt;
&lt;p&gt;Coming to the query which you have: &lt;br /&gt;As ESB is one of the supported protocols in the SDK, we has &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/protocols/esb/index.html"&gt;This ESB user guide&lt;/a&gt;&amp;nbsp;that describes what it is and how to use with nordic devices.&lt;br /&gt;Within the product specification, we see that the clock system has &amp;quot;start&amp;quot; and &amp;quot;stop&amp;quot; tasks and have two corresponding events called &amp;quot;started&amp;quot; and &amp;quot;stopped&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1699904573897v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;To start the HFClock, we need to set/enable the &amp;quot;start&amp;quot; task for HFClock and wait till it has been enabled.&lt;br /&gt;To stop the HFClock, we need to set/enable the &amp;quot;stop&amp;quot; task for HFClock and wait till it has been disabled.&lt;/p&gt;
&lt;p&gt;Showing sample code for starting HFClock:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>