<?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 clock in and out</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12177/nrf52-clock-in-and-out</link><description>I have two related questions about nRF52 (nrf52832) which I have not been able to pinpoint from the documentation. 
 
 
 Can the 32MHz crystal connection be replaced by a 32MHz input if there is an existing clock in the system that meets the precision</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 06 Jun 2020 17:27:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12177/nrf52-clock-in-and-out" /><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/253643?ContentTypeID=1</link><pubDate>Sat, 06 Jun 2020 17:27:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6d707d2-2434-44b2-9682-69c723a8e054</guid><dc:creator>mydadisaplumber</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;I came across this question. I&amp;#39;m confused because in the docs for the Clock of the nRF52 here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fclock.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fclock.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It seems to suggest you can use a 32 MHz clock with the nRF52 as a source for the HFXO. I&amp;#39;ve read the clock section of the docs a few time and still don&amp;#39;t understand.&lt;/p&gt;
&lt;p&gt;If there&amp;#39;s no external 32 MHz clock, what&amp;#39;s the HFXO source? Internal?&lt;/p&gt;
&lt;p&gt;Why is it that all functionality can be done with no HF external clock, but a lot of other forum posts seem to suggest that you can&amp;#39;t use Soft Device or BLE if you use an internal RC filter for the LFXO. Is that true? Is the 32.768 kHz external clock required for full nRF52 functionality?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/120302?ContentTypeID=1</link><pubDate>Thu, 08 Feb 2018 14:44:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:129e6f0b-d56f-4550-bd75-06fb313bc0b1</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Replying to myself.&lt;/p&gt;
&lt;p&gt;I just found why my code does not start the 4MHz code after the start of the BlueTooth. Because I was trying to write clean/futureproof code I used the&amp;nbsp;&lt;code&gt;nrf_drv_clock_hfclk_request&lt;/code&gt; function in order to make sure&amp;nbsp;that the&amp;nbsp;fast clock at 16MHz is running and stable before to start the timer.&lt;/p&gt;
&lt;p&gt;If instead of this I directly do the&amp;nbsp;&lt;code&gt;NRF_TIMER1-&amp;gt;TASKS_START = 1;&lt;/code&gt; like in the original code, then the 4MHz clock is generated.&lt;/p&gt;
&lt;p&gt;So, my comment is that the way I start the BlueTooth does something wrong with the clock driver. Your help about this is welcome&amp;hellip;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/120292?ContentTypeID=1</link><pubDate>Thu, 08 Feb 2018 14:09:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:785efe7d-a797-4d42-86ff-73ab4ef9686f</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am also interested in outputting a 4MHz clock from nRF52 (actually I am using nRF52832). I have a few comments question on the code that you have supplied:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Concerning this piece of code:&amp;nbsp;[quote userid="6606" url="~/f/nordic-q-a/12177/nrf52-clock-in-and-out/46076#46076"]nrf_gpio_range_cfg_output(18); //Configure pin 18 as output[/quote]I am using&amp;nbsp;nRF5_SDK_14.2.0_17b948a, and there seems that the&amp;nbsp;&lt;code&gt;nrf_gpio_range_cfg_output&lt;/code&gt; function takes 2 arguments (both ends of the range), so you need&amp;nbsp;&lt;code&gt;nrf_gpio_cfg_output&lt;/code&gt; driver function instead.&lt;/li&gt;
&lt;li&gt;Concerning this piece of code:[quote userid="6606" url="~/f/nordic-q-a/12177/nrf52-clock-in-and-out/46076#46076"]NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1; //Start high frequency clock&lt;br /&gt; while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Wait for HFCLK to start&lt;br /&gt; }&lt;br /&gt; NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0; //Clear event[/quote]I think it would be cleaner to use the driver functions for code futureproofness/portability, would the following make it:&lt;br /&gt;
&lt;pre&gt;  if(!nrf_drv_clock_init_check())
    {
      err_code = nrf_drv_clock_init();
      APP_ERROR_CHECK(err_code);
    }
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Same comment for the PPI configuration, wouldn&amp;#39;t it be cleaner if we used some driver call for this piece of code&amp;nbsp;[quote userid="6606" url="~/f/nordic-q-a/12177/nrf52-clock-in-and-out/46076#46076"]//Configure PPI&lt;br /&gt; NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t) &amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];&lt;br /&gt; NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[0];&lt;br /&gt;&lt;br /&gt; NRF_PPI-&amp;gt;CHENSET = PPI_CHENSET_CH0_Enabled &amp;lt;&amp;lt; PPI_CHENSET_CH0_Pos; [/quote]like this:&lt;br /&gt;
&lt;pre&gt;    void my_clock_start_handler(nrf_drv_clock_evt_type_t event)
    {
      if(event == NRF_DRV_CLOCK_EVT_HFCLK_STARTED)
        NRF_TIMER1-&amp;gt;TASKS_START = 1;
      else
        APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);
    }
    
    nrf_drv_clock_handler_item_t my_clock_handler_item_s = {
      .p_next = NULL,
      .event_handler = &amp;amp;my_clock_start_handler
    };
    
    void my_clock_start(void)
    {
    
      nrf_drv_ppi_init();
      err_code = nrf_drv_ppi_channel_alloc	(&amp;amp;my_4MHz_clck_ppi_channel_s);
      APP_ERROR_CHECK(err_code);
      
      err_code = nrf_drv_ppi_channel_assign	(my_4MHz_clck_ppi_channel_s,
     					 (uint32_t) &amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0],
     					 (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[0] );	  
      APP_ERROR_CHECK(err_code);
    
      err_code = nrf_drv_ppi_channel_enable(my_4MHz_clck_ppi_channel_s);
      APP_ERROR_CHECK(err_code);
    
      nrf_drv_clock_hfclk_request(&amp;amp;my_clock_handler_item_s);
    }
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Now, last but not least, I have one more question. I noticed that the code above does not work any longer after any call to &lt;code&gt;NVIC_DisableIRQ(POWER_CLOCK_IRQn);&lt;/code&gt;&lt;br /&gt; For instance, when the SoftDevice is present, and the &lt;code&gt;nrf_sdh_enable_request&lt;/code&gt; function from &lt;code&gt;nrf-sdk/components/softdevice/common/nrf_sdh.c&lt;/code&gt; is called, then this function calls function &lt;code&gt;sdh_state_observer_notify&lt;/code&gt; from the same file which in turn runs some state observers hooks, amongst which the &lt;code&gt;sd_state_evt_handler&lt;/code&gt; from the &lt;code&gt;nrf-sdk/components/drivers_nrf/clock/nrf_drv_clock.c&lt;/code&gt; file, which in turns calls &lt;code&gt;NVIC_DisableIRQ(POWER_CLOCK_IRQn);&lt;/code&gt;.&lt;br /&gt;I would be quite greatfull to get some feedback why this happens&amp;hellip;&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/46080?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 14:59:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a13effa-2d89-41a9-975e-a22b10c08936</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;The answer to question # 1 is &lt;em&gt;no&lt;/em&gt;, it is not supported. It was possible on the nRF51, but the clock module is redesigned and external 32MHz clocks is not a feature of nRF52. You can try at your own discretion, but the new design is so sensitive to jitter and noise that Nordic will not make any guarantees. A crystal is needed to ensure performance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/46079?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 14:53:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c9658f6-510b-41a6-9ccb-9b97aea2bcd2</guid><dc:creator>Greg Nelson</dc:creator><description>&lt;p&gt;The back-of-the-envelope is very helpful, since I don&amp;#39;t have the tools to measure currents in the uA range at my immediate disposal.  I was just wondering if the GPIOTE functions would contribute noticeable additional power draw - the data sheet only lists IGPIOTE,IN and doesn&amp;#39;t give any info about frequency dependency (uA/MHz).
If I assume a 1.8V supply and &lt;em&gt;only&lt;/em&gt; consider the pad capacitance (data sheet says 3pF except for NFC, but I&amp;#39;ll stick with your 4pF for consistency), your formula and the resulting 5kΩ gives about 360uA per pin.
In contrast, the formula from the datasheet (pg. 151: IGPIO=VDD Cload f) gives about 58uA per pin.
I&amp;#39;m not sure which of these is a better estimate, but they are rather different.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/46078?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 14:39:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a140fc5f-475d-4821-a0a7-c6b6c68e2b08</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Well we have a pin capacitance of 4pF at each GPIO, the pulse moves at 8MHz and we know the relation X_C = 1/ ω C, this gives a equivalent resistance of approximately 5kΩ. Then you will have to add what you end up connecting to the pad. In the end the power consumed will be approximately equal to the power going through the equivalent resistor.&lt;/p&gt;
&lt;p&gt;Alternately you can set up this on your development kit and measure the difference in current draw with and without 8MHz output. Please refer to the &lt;a href="https://devzone.nordicsemi.com/tutorials/28/"&gt;current measurement guide&lt;/a&gt; for practical information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/46075?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 14:30:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89ecf9f5-2513-4055-a3c1-fb5dd9119209</guid><dc:creator>Greg Nelson</dc:creator><description>&lt;p&gt;Just to be clear, for my second point, it is fine that I can&amp;#39;t get 32MHz or 64MHz out (&amp;quot;&lt;strong&gt;the&lt;/strong&gt; high frequency clock&amp;quot;); the design simply requires some clock in the MHz range (&amp;quot;&lt;strong&gt;a&lt;/strong&gt; high frequency clock&amp;quot;) and the power drawn by the nRF52 is orders of magnitude lower than typical crystal oscillators drawing several mA.  We just want to get the power as low as possible.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/46077?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 14:16:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12c2f32e-1e3f-4621-a01b-439e71a08b8b</guid><dc:creator>Greg Nelson</dc:creator><description>&lt;p&gt;This is excellent information - I believe that 8MHz would work well for our needs.  Is there any simple way to estimate of the power impact of the GPIOTE solution listed above?  I assume it&amp;#39;s more complex that just C&lt;em&gt;f&lt;/em&gt;V^2 for the I/O pin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 clock in and out</title><link>https://devzone.nordicsemi.com/thread/46076?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 09:56:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a88f3b7a-d31e-4530-bc63-eee995c77070</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;See Martin&amp;#39;s answer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The peripherals only run at 16MHz, this is why it is not possible to get HFCLK output from the nRF52. Max output is 8MHz, since you need to toggle on and off a pin. This is achieved using GPIOTE and PPI with the following code which creates a 8MHz output on pin 18:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; int main(void)
 {
 nrf_gpio_range_cfg_output(18); //Configure pin 18 as output

 NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1; //Start high frequency clock
 while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
 {
      //Wait for HFCLK to start
 }
 NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0; //Clear event
 
 
 //Configure GPIOTE to toggle pin 18 
 NRF_GPIOTE-&amp;gt;CONFIG[0] = GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos |
                         GPIOTE_CONFIG_POLARITY_Toggle &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos |
                         18 &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos | 
                         GPIOTE_CONFIG_OUTINIT_Low &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos;
 
 //Configure timer
 NRF_TIMER1-&amp;gt;PRESCALER = 0;
 NRF_TIMER1-&amp;gt;CC[0] = 1;  // Adjust the output frequency by adjusting the CC.
 NRF_TIMER1-&amp;gt;SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled &amp;lt;&amp;lt; TIMER_SHORTS_COMPARE0_CLEAR_Pos;
 NRF_TIMER1-&amp;gt;TASKS_START = 1;
 
 //Configure PPI
 NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t) &amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];
 NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[0];
 
 NRF_PPI-&amp;gt;CHENSET = PPI_CHENSET_CH0_Enabled &amp;lt;&amp;lt; PPI_CHENSET_CH0_Pos;
 
 while (true)
 {
     // do nothing
 }
 }
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&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>