<?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, 1-4 MHz clock needed</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13430/nrf52-1-4-mhz-clock-needed</link><description>I am using the nRF52 Preview board, PCA 10036. I need to provide a high-frequency clock signal to a peripheral. Anything between 1 and 4 MHz will work. However, I don&amp;#39;t need and don&amp;#39;t want the CPU to receive an interrupt on every clock pulse. 
 I think</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 25 Apr 2016 22:32:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13430/nrf52-1-4-mhz-clock-needed" /><item><title>RE: nRF52, 1-4 MHz clock needed</title><link>https://devzone.nordicsemi.com/thread/51271?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2016 22:32:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:144aa520-3ce9-4ec2-9b7c-f6af2b767234</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;But RK, Øyvind was missing two lines!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That makes 20 lines exactly.  :^)&lt;/p&gt;
&lt;p&gt;Thanks to you both, I got most of the way there on my own with your guidance.  But Øyvind&amp;#39;s code works right out of the box, and I can proceed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52, 1-4 MHz clock needed</title><link>https://devzone.nordicsemi.com/thread/51270?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2016 07:58:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecae7961-481b-45b5-b134-48a7fedb2460</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;18 lines - I guessed 20 - I must be slipping :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52, 1-4 MHz clock needed</title><link>https://devzone.nordicsemi.com/thread/51269?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2016 07:06:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c59868e-3ce5-4949-929c-1d26f51adad9</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I wrote some code for this earlier, for 4 MHz output on pin 18 set NRF_TIMER1-&amp;gt;CC[0] = 2;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
    // Set up GPIO as output
    nrf_gpio_range_cfg_output(17, 18);
    nrf_gpio_pin_clear(17); // Light LED 1 to indicate that the code is running
    
    // Start high frequency clock
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
    {
        // Wait for clock to start
    }
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    
    // 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;
                            
    // Set up 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;
        
    // Set up PPI to connect the timer compare event with the GPIOTE toggle task
    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)
    {
       
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The principle is well described by RKs post. You can find relevant documentation in the infocenter:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.0/ppi.html?cp=1_2_0_20#concept_sxf_21l_1s"&gt;Programmable Peripheral Interconnect (PPI)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.0/gpio.html?cp=1_2_0_18#concept_zyt_tcb_lr"&gt;General Purpose Input Output (GPIO)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.0/gpiote.html?cp=1_2_0_19#concept_knz_kww_lr"&gt;GPIOTE (GPIO Tasks and Events)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.0/timer.html?cp=1_2_0_22#concept_xbd_hqp_sr"&gt;Timer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&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><item><title>RE: nRF52, 1-4 MHz clock needed</title><link>https://devzone.nordicsemi.com/thread/51267?ContentTypeID=1</link><pubDate>Sat, 23 Apr 2016 03:17:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42ae5786-3488-41f6-bad8-17c56720824a</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;yeah you don&amp;#39;t need the hardware drivers for this - it should be no more than about 20 lines of code to set it up and make it run.&lt;/p&gt;
&lt;p&gt;Break it down. Job #1, configure a TIMER to count at 16MHz (no scaler) and set COMPARE[0], or another COMPARE to &amp;#39;4&amp;#39; for 4MHz or &amp;#39;16&amp;#39; for 1MHz. Enable the SHORTS for COMPARE[0] and CLEAR. That&amp;#39;s all chapter 24 of the manual. Now you have a timer which counts at the right rate.&lt;/p&gt;
&lt;p&gt;Next look up GPIOTE, chapter 21. Configure one of those to Task mode, on a pin you select, with polarity == TOGGLE. Each time you trigger GPIOTE-&amp;gt;TASKS_OUT[your task number] the pin will toggle. Test that.&lt;/p&gt;
&lt;p&gt;Now hook those two up with PPI, chapter 22. CH[].TEP is the task address, that&amp;#39;s the GPIOTE, CH[].EEP is the event, that&amp;#39;s the TIMER COMPARE event, set those, enable the channel, now everytime the timer gets to 4, it will clear and trigger, via the PPI, the pin to toggle.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52, 1-4 MHz clock needed</title><link>https://devzone.nordicsemi.com/thread/51268?ContentTypeID=1</link><pubDate>Sat, 23 Apr 2016 02:23:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9463045-d292-4799-a16d-b4d0d58f52e6</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Thanks for your reply, RK.  You may not recognize my name, but I&amp;#39;m rather new to embedded systems programming, and you have helped me several times.&lt;/p&gt;
&lt;p&gt;I think you are telling me that I guessed correctly when I said that I need to program at a lower level.  I won&amp;#39;t use the timer driver, instead I use the hardware abstraction layer.  This may apply to other parts of the program too, I&amp;#39;m not sure yet.&lt;/p&gt;
&lt;p&gt;I am reading through the hardware specification for the chip and trying to grasp all that it can do.  The SDK examples do not show any of this low-level programming.  If you know where I can see and learn more, I would appreciate a link.  Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52, 1-4 MHz clock needed</title><link>https://devzone.nordicsemi.com/thread/51266?ContentTypeID=1</link><pubDate>Sat, 23 Apr 2016 00:54:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2908a3f-101e-4260-9eb7-08b228d46639</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;seems pretty simple - run one of the TIMERs, set the COMPARE to whatever gives you 1-4MHz, enable the short between COMPARE and CLEAR and set up a PPI to toggle a GPIO pin on the COMPARE event. Now you have a 1-4MHz toggling GPIO pin with no CPU involvement, just the power use from the HKCLK running.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52, 1-4 MHz clock needed</title><link>https://devzone.nordicsemi.com/thread/51265?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2016 23:44:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48104283-5de5-42e4-8d6d-0748e055e4dc</guid><dc:creator>Ladasky</dc:creator><description>&lt;p&gt;Following up to myself:&lt;/p&gt;
&lt;p&gt;I am looking for something similar to this example for the nRF51822, but for the nRF52 series.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/23854/how-to-get-3mhz5mhz-clock-signal-out-from-gpio-of-nrf51822/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I know that there have been some significant changes between the two devices.  I don&amp;#39;t want to start following an outdated example, only to find that it doesn&amp;#39;t work for me.  Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>