<?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>HFCLKSTAT and an external crystal</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4675/hfclkstat-and-an-external-crystal</link><description>I&amp;#39;ve got a custom board here, the debugger is reporting that HFCLKSTAT is 0x00010000. Which I think is translating as using the RC oscillator rather than the external crystal. Any suggestions on what to check?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Dec 2014 16:28:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4675/hfclkstat-and-an-external-crystal" /><item><title>RE: HFCLKSTAT and an external crystal</title><link>https://devzone.nordicsemi.com/thread/16580?ContentTypeID=1</link><pubDate>Tue, 02 Dec 2014 16:28:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e596046c-cfe7-42dd-8332-66a5c39dc5d6</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Does your board have an external 32 kHz crystal? I believe all SDK examples are configured to use an external 32 kHz crystal. This can be changed to use the internal 32 kHz RC oscillator in ble_stack_init() if yours doesn&amp;#39;t have a crystal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HFCLKSTAT and an external crystal</title><link>https://devzone.nordicsemi.com/thread/16579?ContentTypeID=1</link><pubDate>Tue, 02 Dec 2014 16:03:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8315408f-a5cd-40de-bf57-066eb0bd2d59</guid><dc:creator>Jim Credland</dc:creator><description>&lt;p&gt;Great stuff. Thank you. Tried it and my crystal is go! Looks like the clock is working and I have a softdevice startup problem of some other kind.  Will work on that.  Always a relief if the hardware works ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HFCLKSTAT and an external crystal</title><link>https://devzone.nordicsemi.com/thread/16578?ContentTypeID=1</link><pubDate>Tue, 02 Dec 2014 01:53:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e25daf87-5aac-4119-b34b-7f82e740099c</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Hi Jim,&lt;/p&gt;
&lt;p&gt;you&amp;#39;re right. HFCLKSTAT value of 0x00010000 indicates that the internal 16 MHz RC oscillator is generating the 16 MHz clock. To use the external 16 MHz crystal as the 16 MHz clock source instead, you can trigger the HFCLKSTART task. Note that the CLOCK peripheral is blocked by the softdevice when the softdevice is enabled.
After the crystal has started (startup time can vary) HFCLKSTAT should change to 0x00010001.&lt;/p&gt;
&lt;p&gt;The following code can be used to start the clock and make sure it&amp;#39;s running:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_GPIO-&amp;gt;DIRSET = (1 &amp;lt;&amp;lt; DEBUG_PIN); // Use LED or other accessible pin if you want to observe the application state
NRF_GPIO-&amp;gt;OUTCLR = (1 &amp;lt;&amp;lt; DEBUG_PIN); 

NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART    = 1;
while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
{
    // Wait for started event to occur. Note: will spin forever if crystal isnt working
    __NOP();
}

// 16 MHz XTAL has now started
NRF_GPIO-&amp;gt;OUTSET = (1 &amp;lt;&amp;lt; DEBUG_PIN); 
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>