<?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>Updating PWM output signal</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44564/updating-pwm-output-signal</link><description>Hi, May be it&amp;#39;s some what basic but I&amp;#39;m not able to update my pwm value. I&amp;#39;m using sdk 14.02 with softdevice in SES. This is my code: 
 PWM Config: 
 
 
 
 PWM init: 
 Update pwm value in pwm event handler: 
 
 
 
 Update pwm sequence:</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 Mar 2019 15:14:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44564/updating-pwm-output-signal" /><item><title>RE: Updating PWM output signal</title><link>https://devzone.nordicsemi.com/thread/176481?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 15:14:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91b4d2ba-ad1b-4c50-b5d7-fc0e09a2ebf6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I run your application, it runs into the hardfault handler. Does the same happen for you?&lt;/p&gt;
&lt;p&gt;Does the application all of the sudden stop?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating PWM output signal</title><link>https://devzone.nordicsemi.com/thread/175959?ContentTypeID=1</link><pubDate>Wed, 13 Mar 2019 13:40:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ddb6846-0898-431f-8820-e77fd004e654</guid><dc:creator>Kapil Rawat</dc:creator><description>&lt;p&gt;I tested below PWM code without soft-device, it&amp;#39;s working fine but not above code.&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&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;app_timer.h&amp;quot;
#include &amp;quot;nrf_drv_clock.h&amp;quot;

#include &amp;quot;nrf_delay.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

uint16_t pwm_val=0;
static nrf_drv_pwm_t m_pwm0 = NRF_DRV_PWM_INSTANCE(0);
static uint16_t const              m_demo1_top  = 10000;
static uint16_t const              m_demo1_step = 200;
static uint8_t                     m_demo1_phase;
static nrf_pwm_values_individual_t m_demo1_seq_values;
static nrf_pwm_sequence_t const    m_demo1_seq =
{
    .values.p_individual = &amp;amp;m_demo1_seq_values,
    .length              = NRF_PWM_VALUES_LENGTH(m_demo1_seq_values),
    .repeats             = 0,
    .end_delay           = 2000
};

void update()
{
     if(pwm_val&amp;lt;=10000)
     {
        m_demo1_seq_values.channel_0 = pwm_val;
        pwm_val+=5;
    
    
     }
     else if(pwm_val&amp;gt;10000)
     {
        m_demo1_seq_values.channel_0 = pwm_val;
        pwm_val=0;
    
    
     }
     (void)nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;m_demo1_seq, 1,0);
    
}

static void demo1_handler(nrf_drv_pwm_evt_type_t event_type)
{
    if (event_type == NRF_DRV_PWM_EVT_FINISHED)
    {
        //update();
          (void)nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;m_demo1_seq, 1,0);

     
    }
}
static void demo1(void)
{
    NRF_LOG_INFO(&amp;quot;Demo 1&amp;quot;);

    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            ARDUINO_1_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    = m_demo1_top,
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    APP_ERROR_CHECK(nrf_drv_pwm_init(&amp;amp;m_pwm0, &amp;amp;config0, demo1_handler));
    
    m_demo1_seq_values.channel_0 = 0;
    m_demo1_seq_values.channel_1 = 0;
    m_demo1_seq_values.channel_2 = 0;
    m_demo1_seq_values.channel_3 = 0;
    m_demo1_phase                = 0;

    (void)nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;m_demo1_seq, 1,0);
}


int main(void)
{
    
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_INFO(&amp;quot;PWM example&amp;quot;);

    demo1();

    for (;;)
    {
        // Wait for an event.
        __WFE();

        // Clear the event register.
        __SEV();
        __WFE();
          update(); 
          nrf_delay_us(1000);

     
      
    }
}


/** @} */
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating PWM output signal</title><link>https://devzone.nordicsemi.com/thread/175677?ContentTypeID=1</link><pubDate>Tue, 12 Mar 2019 13:22:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac7ed58b-2054-4454-bbfa-33497125c87e</guid><dc:creator>Kapil Rawat</dc:creator><description>&lt;p&gt;## HW Requirements&lt;/p&gt;
&lt;p&gt;- nRF52832 Development Kit&lt;/p&gt;
&lt;p&gt;## SW Requirements&lt;/p&gt;
&lt;p&gt;- nRF5 SDK v14.2.0&lt;/p&gt;
&lt;p&gt;- Segger Embedded Studio&lt;/p&gt;
&lt;p&gt;code:&lt;br /&gt;&lt;br /&gt;&lt;a href="https://drive.google.com/open?id=1ncMl64SKrXc8B7FNk0-cf7Zc4l0AxQJ4"&gt;drive.google.com/open&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating PWM output signal</title><link>https://devzone.nordicsemi.com/thread/175450?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2019 16:09:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:789e1a3a-2998-403a-9242-3036e535dc05</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Can you upload the project here? Just zip the pwm_driver folder from SDK\examples\peripheral (if that is the project you are using). If you have trouble uploading it, try to delete the build files before zipping the folder. This will reduce the size drastically.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also, please specify what IDE you used (Keil? Segger Embedded Studio? other?) and what SDK version you use.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating PWM output signal</title><link>https://devzone.nordicsemi.com/thread/175219?ContentTypeID=1</link><pubDate>Sun, 10 Mar 2019 21:05:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58c284a4-0aee-4c37-9576-e75964acd924</guid><dc:creator>Kapil Rawat</dc:creator><description>&lt;p&gt;Here it&amp;#39;s getting update but not output side(Pin out)&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  nrf_drv_pwm_simple_playback(&amp;amp;m_base_pwm, &amp;amp;pwm_seq_2, 1, 0);

    NRF_LOG_INFO(&amp;quot;PWM0 C value: %d&amp;quot;, *pwm_seq_2.values.p_common); 
    NRF_LOG_INFO(&amp;quot;PWM0 I value: %d&amp;quot;, (*pwm_seq_2.values.p_individual).channel_0); &lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating PWM output signal</title><link>https://devzone.nordicsemi.com/thread/175129?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2019 18:17:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e03149da-b9b7-437d-bfb1-d4747c97c4ad</guid><dc:creator>Kapil Rawat</dc:creator><description>&lt;p&gt;Yes I check it&amp;#39;s going to pwm_timer_timeout_handler.&lt;br /&gt;I checked my seq value and it&amp;#39;s updating but in PWM pin output I&amp;#39;m not getting any change&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; NRF_LOG_INFO(&amp;quot;PWM updated value: %d&amp;quot;, *pwm_seq.values.p_common);
   &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating PWM output signal</title><link>https://devzone.nordicsemi.com/thread/175085?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2019 15:04:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f79134cb-86a4-4579-85c4-4e271745e45f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Have you tried debugging to see that the update functions are actually called?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>