<?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>Is it possible to use high drive mode with PWM?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85026/is-it-possible-to-use-high-drive-mode-with-pwm</link><description>Hi, 
 I want to drive an RGB via PWM and need to increase the brightness. Is it possible to configure the pins to high drive mode? Is there a specific sequence that needs to be followed (first set the drive strength, then the PWM, or the other way around</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Feb 2022 09:12:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85026/is-it-possible-to-use-high-drive-mode-with-pwm" /><item><title>RE: Is it possible to use high drive mode with PWM?</title><link>https://devzone.nordicsemi.com/thread/354493?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 09:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:328280b6-8a76-458a-9d23-61586579ac98</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, you can select high drive for the PWM outputs. The problem is that the PWM driver does not expose the drive strength as a configuration setting, so you either have to modify the driver code, or change the drive strength after the pwm has been enabled by nrf_drv_pwm_init().&lt;/p&gt;
&lt;p&gt;Option 1: modify driver code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void configure_pins(nrfx_pwm_t const * const p_instance,
                           nrfx_pwm_config_t const * p_config)
{
    uint32_t out_pins[NRF_PWM_CHANNEL_COUNT];
    uint8_t i;

    for (i = 0; i &amp;lt; NRF_PWM_CHANNEL_COUNT; ++i)
    {
        uint8_t output_pin = p_config-&amp;gt;output_pins[i];
        if (output_pin != NRFX_PWM_PIN_NOT_USED)
        {
            bool inverted = output_pin &amp;amp;  NRFX_PWM_PIN_INVERTED;
            out_pins[i]   = output_pin &amp;amp; ~NRFX_PWM_PIN_INVERTED;

            if (inverted)
            {
                nrf_gpio_pin_set(out_pins[i]);
            }
            else
            {
                nrf_gpio_pin_clear(out_pins[i]);
            }

#if PWM_HIGH_DRIVE
            nrf_gpio_cfg(out_pins[i], NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT,
                NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_H0H1, NRF_GPIO_PIN_NOSENSE);
#else 
            nrf_gpio_cfg_output(out_pins[i]);
#endif

        }
        else
        {
            out_pins[i] = NRF_PWM_PIN_NOT_CONNECTED;
        }
    }

    nrf_pwm_pins_set(p_instance-&amp;gt;p_registers, out_pins);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Option 2: Change drive strength after nrf_drv_pwm_init()&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    APP_ERROR_CHECK(nrf_drv_pwm_init());
   NRF_P0-&amp;gt;PIN_CNF[&amp;lt; pin number on port 0 &amp;gt;] |= (GPIO_PIN_CNF_DRIVE_H0H1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>