<?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>maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8153/maximum-clock-possible-on-gpio-pin-nrf51</link><description>Hallo everyone.
I&amp;#39;m working with the processor nRF51422 with S210 softdevice and I would like to use the HFCLK crystal oscillator for clocking another external periferal, only during the on-mode period of the system to reduce the overall power consumption</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Nov 2017 08:15:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8153/maximum-clock-possible-on-gpio-pin-nrf51" /><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29319?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2017 08:15:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f132d4c6-8e7b-4b7a-a2a5-fdf54ffba4f9</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Milk, probably it was fixed later then. I will check that and update my answer soon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29320?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2017 02:22:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe566e2f-f32d-4ca3-87b2-2cca1d833c55</guid><dc:creator>Milk</dc:creator><description>&lt;p&gt;Hi Aryan,
Your opinion is SDK9.0 and SDK 8.1 should fix this problem,why SDK11 stay the same?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29318?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2015 14:12:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e53871db-4cd3-4176-a048-f254c2a70fc5</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thanks Sebastiano for coming back here to report your results.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29317?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2015 10:36:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:272eec0f-4c13-418e-91a3-8b254777cbe6</guid><dc:creator>sebastiano.xinet</dc:creator><description>&lt;p&gt;Hi, we made some tests about the 8 MHz clock signal and the given code and, with the specific adaptation for our project, the results are positive so thanks for the tip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29316?ContentTypeID=1</link><pubDate>Thu, 22 Oct 2015 09:47:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2a34319-9c06-4702-9b74-cecfd2684b15</guid><dc:creator>sebastiano.xinet</dc:creator><description>&lt;p&gt;Hi, thank you for the update! We&amp;#39;ll check soon on our nrf51 if the frequency is okay and we&amp;#39;ll reply to you the results. Thanks again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29315?ContentTypeID=1</link><pubDate>Wed, 21 Oct 2015 11:06:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a88513b9-f597-4d15-83b6-76b9dac2275e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The given diagram is wrong, it was a measurement artifact. nRF51 was able to generate stable 8MHz clock this way. I checked this on oscilloscope. Apparently Logic analyser 16 sampling cannot be 100% trusted all the time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29314?ContentTypeID=1</link><pubDate>Tue, 21 Jul 2015 08:00:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f559e85-82d5-46f8-9cbd-7a8b260fa643</guid><dc:creator>sebastiano.xinet</dc:creator><description>&lt;p&gt;Ok I&amp;#39;ll try if I can use also the 4MHz signal for my clock. Thanks a lot for your fast and helpful answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29313?ContentTypeID=1</link><pubDate>Thu, 16 Jul 2015 10:10:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f28d5414-27ae-4d4c-85e9-3bd92735aa7e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;We can generate 4MHz of stable clock with GPIOS, this is recommended and anything out of this is outside the spec.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29312?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2015 16:53:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3cf5142-398a-4c14-91d7-32084c79fd94</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;i will have to investigate more about it, ill come back to you in two days, lets keep this thread open until then&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29311?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2015 16:01:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1ce09d8-c967-41b7-b79d-8e80246027b9</guid><dc:creator>sebastiano.xinet</dc:creator><description>&lt;p&gt;Thanks a lot for your answer. Is it possible to find a solution for the gap problem? Because I need a continuous signal as carrier signal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29310?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2015 07:51:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6aa1017b-e28e-447e-bdb7-89e9951a6135</guid><dc:creator>sebastiano.xinet</dc:creator><description>&lt;p&gt;also the half of the HFCLK could be good. I&amp;#39;ll wait for your test and answer.
Thanks a lot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: maximum clock possible on GPIO pin nrf51</title><link>https://devzone.nordicsemi.com/thread/29309?ContentTypeID=1</link><pubDate>Mon, 13 Jul 2015 19:14:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1861542-d0c0-4dea-958c-56d0ac61d95a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;you cannot get HFCLK bypassed to GPIO, you could probably get half of HFCLK if you configure Timers, GPIOTE and PPI correctly with shorts enabled. I will have to try this out myself tomorrow to confirm. If I succeed, i will give you the configuration for it.&lt;/p&gt;
&lt;h2&gt;Update_14.07.2015&lt;/h2&gt;
&lt;p&gt;Half of HFCLK can be routed to GPIO and This should work even with softdevice.
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2330.Capture.PNG" alt="Half of HFCLK" /&gt;&lt;/p&gt;
&lt;p&gt;anyways as we are now testing the limits of events and tasks I see that there are few gaps happening every millisecond as you can see below. I am not sure if we can do anything about it.
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0486.Capture2.PNG" alt="clock gaps" /&gt;&lt;/p&gt;
&lt;h2&gt;Update_ 21.10.2015&lt;/h2&gt;
&lt;p&gt;The gaps found here in the diagram is a bug from Logic analyzer. Measuring this from oscilloscope showed that the given method gives clean 8MHz clock on pin number 5.
I used this  below code to test on PCA100028 on SDK9.0&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_gpiote.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;

#define TEST_PIN               5
#define GPIOTE_CHANNEL_NUMBER  0 

static void gpiote_init(void)
{
    // Configure GPIO_OUTPUT_PIN_NUMBER as an output.
    nrf_gpio_cfg_output(TEST_PIN);

    // Configure GPIOTE_CHANNEL_NUMBER to toggle the GPIO pin state with input.
    // @note Only one GPIOTE task can be coupled to an output pin.
    nrf_gpiote_task_configure(GPIOTE_CHANNEL_NUMBER, TEST_PIN, \
                           NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
}

static void timer2_init()
{
    // Start 16 MHz crystal oscillator.
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART    = 1;

    // Wait for the external oscillator to start up.
    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
    {
        // Do nothing.
    }
    NRF_TIMER2-&amp;gt;MODE        = TIMER_MODE_MODE_Timer;       // Set the timer in Timer Mode.
    NRF_TIMER2-&amp;gt;PRESCALER   = 0;                          
    NRF_TIMER2-&amp;gt;BITMODE     = TIMER_BITMODE_BITMODE_16Bit; // 16 bit mode.
    NRF_TIMER2-&amp;gt;TASKS_CLEAR = 1;
    NRF_TIMER2-&amp;gt;CC[0]       = 1;
    NRF_TIMER2-&amp;gt;EVENTS_COMPARE[0] = 0;
    NRF_TIMER2-&amp;gt;SHORTS    =
        (TIMER_SHORTS_COMPARE0_CLEAR_Enabled &amp;lt;&amp;lt; TIMER_SHORTS_COMPARE0_CLEAR_Pos);
}

static void ppi_init(void)
{
    // Configure PPI channel 0 to toggle GPIO_OUTPUT_PIN on every TIMER2 COMPARE[0] match (200 ms)
    NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_TIMER2-&amp;gt;EVENTS_COMPARE[0];
    NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[GPIOTE_CHANNEL_NUMBER];

    // Enable PPI channel 0
    NRF_PPI-&amp;gt;CHEN = (PPI_CHEN_CH0_Enabled &amp;lt;&amp;lt; PPI_CHEN_CH0_Pos);
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    // configure TIMER2
    timer2_init();
   
    // configure PPI
    ppi_init();
    
    // configure GPIOTE
    gpiote_init();
    
    NRF_TIMER2-&amp;gt;TASKS_START = 1;  // Start event generation.
    
    while(1);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Update&lt;/h2&gt;
&lt;p&gt;in SDK9.0 and SDK 8.1, nrf_gpiote.h nrf_gpiote_task_configure needs a fix for the above to work. update it with this code&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;__STATIC_INLINE void nrf_gpiote_task_configure(uint32_t idx, uint32_t pin,
                                                nrf_gpiote_polarity_t polarity,
                                                nrf_gpiote_outinit_t  init_val)
{
    /* Check if the output desired is high or low */
    if (init_val == NRF_GPIOTE_INITIAL_VALUE_LOW)
    {
        /* Workaround for the OUTINIT PAN. When nrf_gpiote_task_config() is called a glitch happens
        on the GPIO if the GPIO in question is already assigned to GPIOTE and the pin is in the 
        correct state in GPIOTE but not in the OUT register. */
        NRF_GPIO-&amp;gt;OUTCLR = (1 &amp;lt;&amp;lt; pin);
        
        /* Configure channel to Pin31, not connected to the pin, and configure as a tasks that will set it to proper level */
        NRF_GPIOTE-&amp;gt;CONFIG[idx] = (GPIOTE_CONFIG_MODE_Task       &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos)     |
                                             (31UL                          &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos)     |
                                             (GPIOTE_CONFIG_POLARITY_HiToLo &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos);                                    
    } 
    else 
    {
        /* Workaround for the OUTINIT PAN. When nrf_gpiote_task_config() is called a glitch happens
        on the GPIO if the GPIO in question is already assigned to GPIOTE and the pin is in the 
        correct state in GPIOTE but not in the OUT register. */
        NRF_GPIO-&amp;gt;OUTSET = (1 &amp;lt;&amp;lt; pin);
        
        /* Configure channel to Pin31, not connected to the pin, and configure as a tasks that will set it to proper level */
        NRF_GPIOTE-&amp;gt;CONFIG[idx] = (GPIOTE_CONFIG_MODE_Task       &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos)     |
                                             (31UL                          &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos)     |
                                             (GPIOTE_CONFIG_POLARITY_LoToHi &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos);
    }

    /* Three NOPs are required to make sure configuration is written before setting tasks or getting events */
    __NOP();
    __NOP();
    __NOP(); 

    /* Launch the task to take the GPIOTE channel output to the desired level */
    NRF_GPIOTE-&amp;gt;TASKS_OUT[idx] = 1;
    

    /* Finally configure the channel as the caller expects. If OUTINIT works, the channel is configured properly. 
       If it does not, the channel output inheritance sets the proper level. */
    NRF_GPIOTE-&amp;gt;CONFIG[idx] = (GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos)     |
                                         ((uint32_t)pin    &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos)     |
                                         ((uint32_t)polarity      &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos) |
                                         ((uint32_t)init_val &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos);

    /* Three NOPs are required to make sure configuration is written before setting tasks or getting events */
    __NOP();
    __NOP();
    __NOP(); 
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I have raised an internal ticket for this, it will be solved.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>