<?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>nRF52832 LFCLK external signal and soft device</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15284/nrf52832-lfclk-external-signal-and-soft-device</link><description>Hello, 
 I try to set up an external signal for the LFCLK on a nrf52832. From this question : 
 
 I know the nrf52832 can do this (signal on XL1 pin, XL2 grounded). 
 I know I must set the bits &amp;quot;bypass&amp;quot; and &amp;quot;external clock&amp;quot; in LFCLKSRC register. </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 25 Jul 2016 12:50:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15284/nrf52832-lfclk-external-signal-and-soft-device" /><item><title>RE: nRF52832 LFCLK external signal and soft device</title><link>https://devzone.nordicsemi.com/thread/58385?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2016 12:50:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4075f79-16fa-446d-b590-2c08a4056ca5</guid><dc:creator>apuret</dc:creator><description>&lt;p&gt;With other answers and some studying, I have found the solution:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;external clock signal must be connected to XL1 pin,&lt;/li&gt;
&lt;li&gt;XL2 pin may be left floating or be grounded (if the signal voltage isn&amp;#39;t rail-to-rail),&lt;/li&gt;
&lt;li&gt;LFCLK MUST be configured for external clock signal and started BEFORE enabling the softdevice,&lt;/li&gt;
&lt;li&gt;the softdevice may now be initialized with NRF_CLOCK_LF_SRC_XTAL for the LFCLK.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is a code example (for the nRF52832) :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/* Defines not available in the SDK 11.0.0 */
/* Register: CLOCK_LFCLKSRC */
/* Description: Clock source for the LFCLK */

/* Bits 16 : Enable or disable bypass of LFCLK crystal oscillator with external clock source */
#define CLOCK_LFCLKSRC_BYPASS_Pos (16UL) /*!&amp;lt; Position of BYPASS field. */
#define CLOCK_LFCLKSRC_BYPASS_Msk (0x1UL &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos) /*!&amp;lt; Bit mask of BYPASS field. */
#define CLOCK_LFCLKSRC_BYPASS_Disabled (0UL) /*!&amp;lt; Disabled bypass */
#define CLOCK_LFCLKSRC_BYPASS_Enabled (1UL) /*!&amp;lt; Enable bypass */

/* Bits 17 : Enable or disable external source for LFCLK */
#define CLOCK_LFCLKSRC_EXTERNAL_Pos (17UL) /*!&amp;lt; Position of EXTERNAL field. */
#define CLOCK_LFCLKSRC_EXTERNAL_Msk (0x1UL &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos) /*!&amp;lt; Bit mask of EXTERNAL field. */
#define CLOCK_LFCLKSRC_EXTERNAL_Disabled (0UL) /*!&amp;lt; Disabled external source */
#define CLOCK_LFCLKSRC_EXTERNAL_Enabled (1UL) /*!&amp;lt; Enable external source */

/* Configuring LFCLK to use an external signal */
NRF_CLOCK-&amp;gt;LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos) |
	(CLOCK_LFCLKSRC_BYPASS_Enabled &amp;lt;&amp;lt; CLOCK_LFCLKSRC_BYPASS_Pos ) |
	(CLOCK_LFCLKSRC_EXTERNAL_Enabled &amp;lt;&amp;lt; CLOCK_LFCLKSRC_EXTERNAL_Pos);

/* Starting LFCLK */
NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART = 1;
while (NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0)
{
	/* Nothing to do */
}

/* Initialising softdevice with a &amp;#39;crystal&amp;#39; for LFCLK source (and no scheduler) */
nrf_clock_lf_cfg_t clockLfCfg = {
	.source        = NRF_CLOCK_LF_SRC_XTAL,
	.rc_ctiv       = 0,
	.rc_temp_ctiv  = 0,
	.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM
};
SOFTDEVICE_HANDLER_INIT(&amp;amp;clockLfCfg, NULL);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 LFCLK external signal and soft device</title><link>https://devzone.nordicsemi.com/thread/58384?ContentTypeID=1</link><pubDate>Thu, 21 Jul 2016 11:22:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f8d3b61-cf0f-4020-9d92-8c3eb46aedff</guid><dc:creator>apuret</dc:creator><description>&lt;p&gt;Thanks for your quick answer.
The method you describe was ok for an old SDK, now softdevice_handler_init (and SOFTDEVICE_HANDLER_INIT and SOFTDEVICE_HANDLER_APPSH_INIT) takes a nrf_clock_lf_cfg_t structure as the first parameter. With the SDK 111.0.0, I use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;	#define NRF_CLOCK_LFCLKSRC {							\
	.source        = NRF_CLOCK_LF_SRC_SYNTH,				\
	.rc_ctiv       = 0,									\
	.rc_temp_ctiv  = 0,									\
	.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM	\
}
nrf_clock_lf_cfg_t clockLfCfg = NRF_CLOCK_LFCLKSRC;
SOFTDEVICE_HANDLER_APPSH_INIT(&amp;amp;clockLfCfg, true);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But I need to set the &amp;quot;bypass&amp;quot; and &amp;quot;external clock&amp;quot; bits in LFCLKSRC register and nrf_clock_lf_cfg_t doesn&amp;#39;t help me to do that...&lt;/p&gt;
&lt;p&gt;Do you have any example code to do that?&lt;/p&gt;
&lt;p&gt;-&amp;gt; See &lt;a href="https://devzone.nordicsemi.com/question/88059/nrf52832-lfclk-external-signal-and-soft-device/?answer=88384#post-id-88384"&gt;my own answer&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 LFCLK external signal and soft device</title><link>https://devzone.nordicsemi.com/thread/58383?ContentTypeID=1</link><pubDate>Thu, 21 Jul 2016 10:42:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfd2fc6e-5abb-4fb5-9ef5-d1392d0ece96</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As the post you linked to says you start the clock the same way you start any LF crystal, ie. you call&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Substitute NRF_CLOCK_LFCLKSRC_XTAL_20_PPM with the accuracy of the external clock source you are using.&lt;/p&gt;
&lt;p&gt;Since the SoftDevice uses the LF clock for synchronization is must be left on at all times while the SoftDevice is running.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>