<?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>I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25538/i-have-tried-to-produce-a-pwm-signal-of-33-33khz-at-a-gpio-pin-of-nrf52832-the-duty-cycle-of-the-signal-varies-bizzaredly-even-after-setting-it-to-50-can-anyone-help-me-out-i-wanna-run-an-external-ic-on-this-clock-please-find</link><description>PWM.PNG Here is my code: 
 #include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_drv_rtc.h&amp;quot;
#include &amp;quot;nrf_drv_clock.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;

#define COMPARE_COUNTERTIME (3UL) &amp;lt; Get</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Oct 2017 11:32:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25538/i-have-tried-to-produce-a-pwm-signal-of-33-33khz-at-a-gpio-pin-of-nrf52832-the-duty-cycle-of-the-signal-varies-bizzaredly-even-after-setting-it-to-50-can-anyone-help-me-out-i-wanna-run-an-external-ic-on-this-clock-please-find" /><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100693?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 11:32:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d416af9f-34db-4457-ac7e-c12b11576ee8</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;No, the LFCLK runs at 32 kHz, so you can not get a 50% duty PWM at 33.33khz with the LFCLK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100692?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 11:27:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ac6eac2-c8d7-43d3-9a5f-45d2d06df3ef</guid><dc:creator>Yashur</dc:creator><description>&lt;p&gt;@Sigurd Isn&amp;#39;t there a way to produce this frequency clock using LFCLK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100691?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 14:02:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b7d061f-e6fb-48e0-8053-215f9ffea4c5</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;You could use the PWM library, this will allocates a timer instance and consume 2+4 PPI channels, 1 PPI group, and 2 GPIOTE channels. I.e. it will use more of the resource on the chip to use the PWM library than the PWM peripheral. If this is not a problem for your application, then you can use the PWM library instead if you want.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100694?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 13:54:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22374b5b-1d92-4b82-99e9-98714e9537af</guid><dc:creator>Yashur</dc:creator><description>&lt;p&gt;Hey Sigurd may i know the reason you suggested PWM peripheral in the first place? why didn&amp;#39;t my code work?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100690?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2017 13:12:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51ba96a3-12cb-4b60-a4ea-17458c89cbc3</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;All the driver API is documented at infocenter &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.0.0/modules.html?cp=4_0_0_6"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Since you need 33.33KHz you need to use the HFCLK anyway.  The low-power PWM library that uses the LFCLK have a max frequency around 6kHz.&lt;/p&gt;
&lt;p&gt;To save power, add this to the loop to put the CPU to sleep:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for (;;)
{
    // Use directly __WFE and __SEV macros since the SoftDevice is not available.
    // Wait for event.
    __WFE();

    // Clear Event Register.
    __SEV();
    __WFE();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you could also remove the code in start of main(), i.e. the &lt;code&gt;NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;&lt;/code&gt; and &lt;code&gt;while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);&lt;/code&gt;. Then you will be using the HFINT(internal HF RC) instead of the HF crystal oscillator(HFXO), you will get lower power consumption with HFINT. With this, I&amp;#39;m measuring around 680 µA.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100683?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2017 12:10:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:326ec4ba-652b-4abf-b1c7-cb404029aa80</guid><dc:creator>Yashur</dc:creator><description>&lt;p&gt;Okay! I&amp;#39;ll check and get back to you! Thank You! How do a beginner understand all the api&amp;#39;s? and Why did you suggest pwm peripheral? and your code uses high frequency clock! Isn&amp;#39;t there a better way to consume less power?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100689?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2017 12:06:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f939b666-ce12-45db-b9f8-da9bacd56e40</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Make sure that the code is exactly the same as in my post, and try to rebuild your project.&lt;/p&gt;
&lt;p&gt;Here is a .hex generated from the above code.  It should give 50% duty cycle on PIN 4.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nrf52832_5F00_xxaa_5F00_PWM.hex"&gt;nrf52832_xxaa_PWM.hex&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100688?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2017 12:01:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd31dd4b-43fe-4f7f-b0e5-2545ece24e66</guid><dc:creator>Yashur</dc:creator><description>&lt;p&gt;I need 50% duty cycle and i&amp;#39;m getting only 25! My SDK version is 14 and it&amp;#39;s a nRF52832 board and not a custom board!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100687?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2017 11:57:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09f65bb8-0d20-4cb4-b6e0-12275bb661b0</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;What duty cycle are you measuring? What SDK version are you using? Is this a nRF52-DK or a custom board?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100684?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2017 11:53:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1df3f3b1-543e-41d3-b700-83f49353d4fd</guid><dc:creator>Yashur</dc:creator><description>&lt;p&gt;No, I&amp;#39;m not using Kiel . I&amp;#39;m using windows command prompt! I have got the code running by changing makefile! adding nrf_drv_pwm.h files etc..But the code doesn&amp;#39;t give  a 50% duty cycle signal!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100686?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2017 07:28:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d76a9c55-3cf3-4363-a24e-1c3266f2bc75</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Are you using Keil? Then you need to add the driver to the project, and add the path to the &amp;quot;Include paths&amp;quot;.&lt;/p&gt;
&lt;p&gt;But, e.g. the pwm_driver example should already have all the included paths and files added. The pwm_driver example is located in the folder &lt;code&gt;&amp;lt;SDK_InstallFolder&amp;gt;\examples\peripheral\pwm_driver&lt;/code&gt;. Just remove everything in main.c, and add the code I posted instead.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100685?ContentTypeID=1</link><pubDate>Fri, 06 Oct 2017 05:50:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edf0b64c-ccc1-4ac5-b838-94c3b4ec66c9</guid><dc:creator>Yashur</dc:creator><description>&lt;p&gt;Hey ! Thanks for your support! But i&amp;#39;m getting a compile error saying &amp;quot;nrf_drv_pwm.h&amp;quot; file as not found! May i know how to fix this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I have tried to produce a PWM signal of 33.33KHz at a GPIO pin of nRF52832!The duty cycle of the signal varies bizzaredly even after setting it to 50%!Can anyone help me out! I wanna run an external IC on this clock!Please find the screenshot attached!</title><link>https://devzone.nordicsemi.com/thread/100682?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2017 07:51:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42e4d93f-8f03-4c1e-adc0-3b2ea2fdd70b</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I recommend that you use the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fpwm.html&amp;amp;cp=2_1_0_46&amp;amp;anchor=concept_pzc_1pw_nr"&gt;PWM peripheral&lt;/a&gt; for this.&lt;/p&gt;
&lt;p&gt;The code below will give you a 33.33 KHz clock at 50 % duty at pin 4.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;nrf_drv_pwm.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;nrf_drv_clock.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;


#define OUTPUT_PIN 4

static nrf_drv_pwm_t m_pwm0 = NRF_DRV_PWM_INSTANCE(0);

// Declare variables holding PWM sequence values. In this example only one channel is used 
nrf_pwm_values_individual_t seq_values[] = {0, 0, 0, 0};
nrf_pwm_sequence_t const seq =
{
    .values.p_individual = seq_values,
    .length          = NRF_PWM_VALUES_LENGTH(seq_values),
    .repeats         = 0,
    .end_delay       = 0
};


static void pwm_init(void)
{
    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            OUTPUT_PIN, // channel 0
            NRF_DRV_PWM_PIN_NOT_USED,             // channel 1
            NRF_DRV_PWM_PIN_NOT_USED,             // channel 2
            NRF_DRV_PWM_PIN_NOT_USED,             // channel 3
        },
        .irq_priority = APP_IRQ_PRIORITY_LOWEST,
        .base_clock   = NRF_PWM_CLK_1MHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = 30,
        
        //F(pwm) = F(clk)/top_value
        
        
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    // Init PWM without error handler
    APP_ERROR_CHECK(nrf_drv_pwm_init(&amp;amp;m_pwm0, &amp;amp;config0, NULL));
    
    seq_values-&amp;gt;channel_0 = 15;
    nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;seq, 1, NRF_DRV_PWM_FLAG_LOOP);
    
}


int main(void)
{

    // Start clock for accurate frequencies
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1; 
    // Wait for clock to start
    while(NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0) ;
    
    pwm_init();

    for (;;)
    {
        
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>