<?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 control each channel of hardware PWM individually?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86350/how-to-control-each-channel-of-hardware-pwm-individually</link><description>Hi 
 Thank you for your attention to my question, I would like to inquire how to control each channel of hardware PWM individually, We have 6 LED lights, each LED has different application scenarios, at some point I only want to control one of them, </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 Mar 2022 09:13:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86350/how-to-control-each-channel-of-hardware-pwm-individually" /><item><title>RE: How to control each channel of hardware PWM individually?</title><link>https://devzone.nordicsemi.com/thread/360486?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2022 09:13:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e55040f-9e8a-43b1-9321-7e6dfd42759f</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you seen Demo 3 in the PWM driver example? It would show you how to only use one channel:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void demo3(void)
{
    NRF_LOG_INFO(&amp;quot;Demo 3&amp;quot;);

    /*
     * This demo uses only one channel, which is reflected on LED 1.
     * The LED blinks three times (200 ms on, 200 ms off), then it stays off
     * for one second.
     * This scheme is performed three times before the peripheral is stopped.
     */

    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED, // 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_125kHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = 25000,
        .load_mode    = NRF_PWM_LOAD_COMMON,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    APP_ERROR_CHECK(nrf_drv_pwm_init(&amp;amp;m_pwm0, &amp;amp;config0, NULL));
    m_used |= USED_PWM(0);

    // This array cannot be allocated on stack (hence &amp;quot;static&amp;quot;) and it must
    // be in RAM (hence no &amp;quot;const&amp;quot;, though its content is not changed).
    static uint16_t /*const*/ seq_values[] =
    {
        0x8000,
             0,
        0x8000,
             0,
        0x8000,
             0
    };
    nrf_pwm_sequence_t const seq =
    {
        .values.p_common = seq_values,
        .length          = NRF_PWM_VALUES_LENGTH(seq_values),
        .repeats         = 0,
        .end_delay       = 4
    };

    (void)nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;seq, 3, NRF_DRV_PWM_FLAG_STOP);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>