<?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>How to get 3MHz~5MHz clock signal out from GPIO of nRF51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4988/how-to-get-3mhz-5mhz-clock-signal-out-from-gpio-of-nrf51822</link><description>I want to use nRF51822 to read smart card signal, and smart card need clock signal input. Thanks.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Jul 2016 17:39:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4988/how-to-get-3mhz-5mhz-clock-signal-out-from-gpio-of-nrf51822" /><item><title>RE: How to get 3MHz~5MHz clock signal out from GPIO of nRF51822</title><link>https://devzone.nordicsemi.com/thread/17579?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2016 17:39:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:787ef27c-e811-4988-b7ec-6d7944a84022</guid><dc:creator>guraaf</dc:creator><description>&lt;p&gt;Thanks for the example but I think the PPI task needs to be enabled otherwise it wouldn&amp;#39;t work. I think you need the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_gpiote_task_configure(0, OUTPUT_PIN_NUMBER, \
                           NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_enable(OUTPUT_PIN_NUMBER); // add this
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to get 3MHz~5MHz clock signal out from GPIO of nRF51822</title><link>https://devzone.nordicsemi.com/thread/17578?ContentTypeID=1</link><pubDate>Wed, 07 Jan 2015 13:11:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c94676e-9070-4905-bc79-475f860f6a80</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;You can use a timer and toggle a gpio. The following example will generate a 4MHz signal on a gpio. It uses only HW peripherals.&lt;/p&gt;
&lt;p&gt;Alternatively, you can configure the SPI to output a 4 MHz clock signal, but then you need to constantly write dummy data to the TXD register.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_gpiote.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;

#define OUTPUT_PIN_NUMBER (1)

int main(void)
{
	// Configure OUTPUT_PIN_NUMBER as an output.
    nrf_gpio_cfg_output(OUTPUT_PIN_NUMBER);

    // Configure GPIOTE channel 0 to toggle the pin state
    nrf_gpiote_task_config(0, OUTPUT_PIN_NUMBER, \
                           NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
	
    // Configure PPI channel 0 to toggle OUTPUT_PIN on every TIMER2 COMPARE[0] match.
    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[0];
		
	// Enable PPI channel 0
    NRF_PPI-&amp;gt;CHEN = (PPI_CHEN_CH0_Enabled &amp;lt;&amp;lt; PPI_CHEN_CH0_Pos);
	
    // 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){}
		
	// Configure timer 2
    NRF_TIMER2-&amp;gt;MODE      = TIMER_MODE_MODE_Timer;
    NRF_TIMER2-&amp;gt;BITMODE   = TIMER_BITMODE_BITMODE_16Bit &amp;lt;&amp;lt; TIMER_BITMODE_BITMODE_Pos;
    NRF_TIMER2-&amp;gt;PRESCALER = 0;
	NRF_TIMER2-&amp;gt;SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled &amp;lt;&amp;lt; TIMER_SHORTS_COMPARE0_CLEAR_Pos;

    // Clears the timer, sets it to 0.
    NRF_TIMER2-&amp;gt;TASKS_CLEAR = 1;

    // Load the initial values to TIMER2 CC registers.
    NRF_TIMER2-&amp;gt;CC[0] = 2;
		
	// Start the timer
	NRF_TIMER2-&amp;gt;TASKS_START = 1;
		
	for(;;){}
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>