<?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>NRF52 DK: LF External Crystal Clarification</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45684/nrf52-dk-lf-external-crystal-clarification</link><description>Starting from this example I try to bring clock functionality to my BLE-project. 
 
 1. The external LFCLK-XTAL 
 I need some clarification about the use of the different clock sources on the Development Kit. I searched through the Q&amp;amp;A, but did not find</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 03 Apr 2019 16:44:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45684/nrf52-dk-lf-external-crystal-clarification" /><item><title>RE: NRF52 DK: LF External Crystal Clarification</title><link>https://devzone.nordicsemi.com/thread/180090?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2019 16:44:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3262246-8a28-45ae-9d08-580246bae4bd</guid><dc:creator>wpaul</dc:creator><description>&lt;p&gt;You&amp;#39;re correct in that if you select the LFCLK source to be the crystal and you don&amp;#39;t have one, then things wouldn&amp;#39;t work. But I may have misunderstood something when I read your original post.&lt;/p&gt;
&lt;p&gt;You said: &amp;quot;My board has nothing soldered to this.&amp;quot;&lt;/p&gt;
&lt;p&gt;One question: did you mean &amp;quot;my board&amp;quot; as in &amp;quot;I have a custom board of my own design&amp;quot; or &amp;quot;my board&amp;quot; as in &amp;quot;my own particular nRF52 Development Kit board?&amp;quot;&lt;/p&gt;
&lt;p&gt;I think at first glance I thought you meant the former, but I realize now you probably meant the latter.&lt;/p&gt;
&lt;p&gt;If so (i.e. you&amp;#39;re talking about the nRF52 DK board), then you *do* actually have the 32.768KHz crystal mounted. It&amp;#39;s very small so it may be hard to see it, but it&amp;#39;s there. Hold the board face-up so that the Nordic nRF52 chip is on the right and the J-Link chip and USB plug are on the left. Look closely at the rectangle outline where the nRF52 is mounted. Immediately to the left of the chip you should see X2. To the top and right of the chip, you should see X1.&lt;/p&gt;
&lt;p&gt;X1 is the 32.768KHz crystal and X2 is the 32MHz crystal.&lt;/p&gt;
&lt;p&gt;The term &amp;quot;Optional&amp;quot; in the Nordic documentation is misleading. It&amp;#39;s optional in the sense that depending on your custom application/board design requirements, you may be able to get away without it. (You could chose one of the other LFCLK clock source options instead.) With the DK board, the crystal is there, but you also have the option of cutting two traces on the board to disconnect it so that you can use P0.00 an P0.01 as GPIOs instead. As it is now, you can&amp;#39;t use those pins for that purpose because the crystal is there.&lt;/p&gt;
&lt;p&gt;Note that for the 32MHz crystal, there are two dedicated pins which can&amp;#39;t be used as GPIOs, so there&amp;#39;s no need to ever physically disconnect it.&lt;/p&gt;
&lt;p&gt;Regarding the application timer library. I think this is just a library provided in the SDK which provides application timers which use the RTC1 timer instance as their hardware timer source. At the hardware level, the nRF52 chip provides two kinds of hardware timers:&lt;/p&gt;
&lt;p&gt;TIMER -- 5 instances, driven by the peripheral bus clocks (derived from HFCLK)&lt;/p&gt;
&lt;p&gt;RTC -- 2 instances, driven by the LFCLK&lt;/p&gt;
&lt;p&gt;The RTC uses less power.&lt;/p&gt;
&lt;p&gt;-Bill&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 DK: LF External Crystal Clarification</title><link>https://devzone.nordicsemi.com/thread/179958?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2019 11:11:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2660e0f9-010b-402b-a7e1-0b6c12b02af3</guid><dc:creator>niklas.dahlheimer</dc:creator><description>&lt;p&gt;Hey Bill,&lt;/p&gt;
&lt;p&gt;Thank you very much! Indeed, the code was sloppy and wrong, my appologies!&lt;/p&gt;
&lt;p&gt;The only point where I still stuck is why, if in the sdk_config.h the macro NRF_SDH_CLOCK_LF_SRC is set to 1 (which means NRF_CLOCK_LF_SRC_XTAL, what references to&amp;nbsp;the &lt;span&gt;external 32.768KHz crystal, right?&lt;/span&gt;), the code is working, altough no external 32.768kHz crystal is mounted to my board at the GPIO XTAL soldering points.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And another thing:&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/group__app__timer"&gt;&amp;quot;ApplicationTimer&amp;quot;-Library&lt;/a&gt; has accually nothing to do with the timers which are derived from the HFCLK, right? It looks like the instances of timer-library depend on the RTC which is derived from the LFCLK. So that&amp;#39;s kind of confusing too...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 DK: LF External Crystal Clarification</title><link>https://devzone.nordicsemi.com/thread/179858?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 22:40:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:823382b1-966a-4713-a703-0596f6d14e69</guid><dc:creator>wpaul</dc:creator><description>&lt;p&gt;If I understand things correctly, there are two crystals which you can connect to the nRF52 devices:&lt;/p&gt;
&lt;p&gt;- A 32MHz crystal&lt;/p&gt;
&lt;p&gt;- A 32.768KHz crystal&lt;/p&gt;
&lt;p&gt;The CPU clock and peripheral bus clocks are derived from the high frequency clock (HFCLK). There are two possible sources for the HFCLK: an internal RC oscillator or a 64MHz high frequency crystal oscillator (HFX) which is locked using an external 32MHz crystal.&lt;/p&gt;
&lt;p&gt;At power up, the CPU doesn&amp;#39;t know if it has a crystal connected or not, and there isn&amp;#39;t a strapping pin to tell it, so by default it will run off the internal RC oscillator. You can switch to using the HFXO instead by do the NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART register.&lt;/p&gt;
&lt;p&gt;The real-time clock (RTC) is derived from the low frequency clock (LFCLK). The LFCLK has three possible sources: 1) an internal RC oscillator, 2) an external 32.768KHz crystal, or 3) synthesized from the HFCLK.&lt;/p&gt;
&lt;p&gt;As with the HFCLK, at power-up the chip will use the internal RC oscillator for the LFCLK by default. To change the source you have to write to the NRF_CLOCK-&amp;gt;LFCLKSRC.&lt;/p&gt;
&lt;p&gt;Ideally you&amp;#39;d like to have crystals for both clocks, in order to have the best accuracy and stability.&lt;/p&gt;
&lt;p&gt;I think all that sd_clock_hfclk_request() does is start the HFXO. It doesn&amp;#39;t actually start the HFCLK, because if that clock was not running, the CPU would grind to a halt.&lt;/p&gt;
&lt;p&gt;I think your code is subtly wrong. You only call sd_clock_hfclk_is_running() once. The idea is that this function returns the current state of the HFXO. I think you need to keep calling it so that once the clock does start, you&amp;#39;ll detect it. Also, you&amp;#39;re passing it a NULL pointer. That&amp;#39;s not how this works.&lt;/p&gt;
&lt;p&gt;In other words, I think you want this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t nrf_clock_running_flag;

nrf_clock_running_flag = 0;

while (1) {
        sd_clock_hfclk_is_running (&amp;amp;nrf_clock_running_flag);
        if (nrf_clock_running_flag == 1)
                break;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;-Bill&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>