<?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 change the GPIO output frequency of nRF52832 over 1MHz ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36706/how-to-change-the-gpio-output-frequency-of-nrf52832-over-1mhz</link><description>Dear Sir, 
 I had a project is lighting the LED matrix, we choose the LED IC is TLC5958 and MCU is using nRF52832. 
 Now, we have a question is how to change the GPIO output frequency ? 
 After calculation, the LED IC clock needs 1.524MHz, but we try</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 31 Aug 2018 12:44:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36706/how-to-change-the-gpio-output-frequency-of-nrf52832-over-1mhz" /><item><title>RE: How to change the GPIO output frequency of nRF52832 over 1MHz ?</title><link>https://devzone.nordicsemi.com/thread/146779?ContentTypeID=1</link><pubDate>Fri, 31 Aug 2018 12:44:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f833a9d7-8188-43e9-96fb-00a81597b0d4</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi Wesley,&lt;/p&gt;
&lt;p&gt;Here is a bare-metal code example to get the PWM peripheral&amp;nbsp;&lt;span&gt;to output 1.6MHz on pin 4:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**
 * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */


#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

#define PWM_PIN 4

int16_t buf[] = {(1 &amp;lt;&amp;lt; 15) | 5}; // Inverse polarity (bit 15)


int main(void)
{

    // Start accurate HFCLK (XOSC)
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0) ;
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;

    // Configure PWM_PIN as output, and set it to 0
    NRF_GPIO-&amp;gt;DIRSET = (1 &amp;lt;&amp;lt; PWM_PIN);
    NRF_GPIO-&amp;gt;OUTCLR = (1 &amp;lt;&amp;lt; PWM_PIN);


    NRF_PWM0-&amp;gt;PRESCALER   = PWM_PRESCALER_PRESCALER_DIV_1; // 
    NRF_PWM0-&amp;gt;PSEL.OUT[0] = PWM_PIN;
    NRF_PWM0-&amp;gt;MODE        = (PWM_MODE_UPDOWN_Up &amp;lt;&amp;lt; PWM_MODE_UPDOWN_Pos);
    NRF_PWM0-&amp;gt;DECODER     = (PWM_DECODER_LOAD_Common       &amp;lt;&amp;lt; PWM_DECODER_LOAD_Pos) | 
                            (PWM_DECODER_MODE_RefreshCount &amp;lt;&amp;lt; PWM_DECODER_MODE_Pos);
    NRF_PWM0-&amp;gt;LOOP        = (PWM_LOOP_CNT_Disabled &amp;lt;&amp;lt; PWM_LOOP_CNT_Pos);

    NRF_PWM0-&amp;gt;COUNTERTOP = 10; 


    NRF_PWM0-&amp;gt;SEQ[0].CNT = ((sizeof(buf) / sizeof(uint16_t)) &amp;lt;&amp;lt; PWM_SEQ_CNT_CNT_Pos);
    NRF_PWM0-&amp;gt;SEQ[0].ENDDELAY = 0;
    NRF_PWM0-&amp;gt;SEQ[0].PTR = (uint32_t)&amp;amp;buf[0];
    NRF_PWM0-&amp;gt;SEQ[0].REFRESH = 0;
    NRF_PWM0-&amp;gt;SHORTS = 0;

    NRF_PWM0-&amp;gt;ENABLE = 1;
    NRF_PWM0-&amp;gt;TASKS_SEQSTART[0] = 1;


    while (true)
    {
    __WFE();

    }

}


/** @} */
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to change the GPIO output frequency of nRF52832 over 1MHz ?</title><link>https://devzone.nordicsemi.com/thread/146727?ContentTypeID=1</link><pubDate>Fri, 31 Aug 2018 10:46:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22244954-5d5a-4f4e-89bf-5207099eedbe</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;You can generate 1.6 MHz using a PWM peripherial. You might need to put the GPIO pin in high drive mode in order to achieve a good signal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>