<?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>Which GPIO on nRf52382 can be configured as timer?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12192/which-gpio-on-nrf52382-can-be-configured-as-timer</link><description>I&amp;#39;m using nRF 52383 and need one of the GPIO pins to clock an external device with 4MHz clock.
Can any GPIO be configured as clock output or is there a specific group of GPIO&amp;#39;s that should be used for this purpose?
Looking forward to your reply. 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Feb 2016 09:44:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12192/which-gpio-on-nrf52382-can-be-configured-as-timer" /><item><title>RE: Which GPIO on nRf52382 can be configured as timer?</title><link>https://devzone.nordicsemi.com/thread/46133?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 09:44:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46f9654f-2043-4f91-a149-0e96f65cfe7d</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The following code using GPIOTE with PPI gives a 4MHz 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] = 2;  // 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;p&gt;Because of pin crossbar almost any pin can be used, pin crossbar is essentially a mux that lets you chose any GPIO for any functionality. Please see the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.0/pin.html?cp=1_2_0_2#pin_assign"&gt;pin assignments&lt;/a&gt; for which pins are available for GPIO.&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>