<?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>Hardware PWM doesn&amp;#39;t operate with 100% duty cycle</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/127421/hardware-pwm-doesn-t-operate-with-100-duty-cycle</link><description>Hello 
 I&amp;#39;m currently working SDK upgrade from ncs v2.6.4 to v3.2.1 
 
 I found that, in fade in/out scenario, the PWM works well. however, if it need to turn on in 100%duty cycle, it doesn&amp;#39;t turned on. 
 
 When I compare both driver implementation in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Mar 2026 09:02:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/127421/hardware-pwm-doesn-t-operate-with-100-duty-cycle" /><item><title>RE: Hardware PWM doesn't operate with 100% duty cycle</title><link>https://devzone.nordicsemi.com/thread/563295?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2026 09:02:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ff2bf35-10ef-49a5-aa6c-8f4f7a0814d2</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sorry, forgot to mention that you should rename/delete that file for the purpose of this testing.&lt;/p&gt;
[quote user="Woo-chan Kim"]&lt;p&gt;When I fixed using the `sw_pwm` periperal that you recommend by refer the sample,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;blinky_pwm defines that specifically for the nrf5340dk_nrf5340_cpuapp.overlay board. You can safely use &amp;quot;normal&amp;quot; pwm with it, by deleting that file.&lt;/p&gt;
&lt;p&gt;Check this by searching for &amp;quot;CONFIG_PWM_NRFX&amp;quot; in build/blinky_pwm/zephyr/.config file, and if this is set to &amp;#39;y&amp;#39;; then &amp;quot;NRF_PWM&amp;quot; hardware peripheral is used.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Woo-chan Kim"]&lt;p&gt;I need to control 3 channel pwm to implement full color led.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;sw_pwm is made specifically for 1 channel. Having several will cause issues, as explained here:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/118230/how-to-use-two-sw_pwm-instances-with-nrf5340-with-zephyr/519769"&gt;RE: How to use two sw_pwm instances with nrf5340 with Zephyr?&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware PWM doesn't operate with 100% duty cycle</title><link>https://devzone.nordicsemi.com/thread/563266?ContentTypeID=1</link><pubDate>Mon, 16 Mar 2026 01:05:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17f532ac-a03a-48c4-b6ea-12b35afce73b</guid><dc:creator>Woo-chan Kim</dc:creator><description>&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I fixed using the `sw_pwm` periperal that you recommend by refer the sample,&lt;/p&gt;
&lt;p&gt;it makes error like this.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/opt/nordic/ncs/v3.2.1/zephyr/drivers/pwm/pwm_nrf_sw.c:420:9: error: invalid operands to binary &amp;amp; (have &amp;#39;nrfx_gpiote_t *&amp;#39; and &amp;#39;nrfx_gpiote_t&amp;#39;)
  420 |         &amp;amp;GPIOTE_NRFX_INST_BY_NODE(NRF_DT_GPIOTE_NODE_BY_IDX(_node_id, _prop, _idx))
      |         ^
/Users/woochankim/Project/Firmware-Sense1-Guardian/build_development/Firmware-Sense1-Guardian/zephyr/include/generated/zephyr/devicetree_generated.h:8654:9: note: in expansion of macro &amp;#39;GPIOTE_AND_COMMA&amp;#39;
 8654 |         fn(DT_N_S_sw_pwm, channel_gpios, 1) \
      |         ^~
/opt/nordic/ncs/v3.2.1/zephyr/include/zephyr/devicetree.h:5499:33: note: in expansion of macro &amp;#39;DT_N_S_sw_pwm_P_channel_gpios_FOREACH_PROP_ELEM&amp;#39;
 5499 | #define DT_CAT4(a1, a2, a3, a4) a1 ## a2 ## a3 ## a4
      |                                 ^~
/opt/nordic/ncs/v3.2.1/zephyr/include/zephyr/devicetree.h:5271:9: note: in expansion of macro &amp;#39;DT_FOREACH_PROP_ELEM&amp;#39;
 5271 |         DT_FOREACH_PROP_ELEM(DT_DRV_INST(inst), prop, fn)
      |         ^~~~~~~~~~~~~~~~~~~~
/opt/nordic/ncs/v3.2.1/zephyr/drivers/pwm/pwm_nrf_sw.c:425:17: note: in expansion of macro &amp;#39;DT_INST_FOREACH_PROP_ELEM&amp;#39;
  425 |                 DT_INST_FOREACH_PROP_ELEM(0, channel_gpios, GPIOTE_AND_COMMA)
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I need to control 3 channel pwm to implement full color led.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;this is the overlay that i used to.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pwm0 {
    status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;sw_pwm {
    status = &amp;quot;okay&amp;quot;;
    channel-gpios = &amp;lt;&amp;amp;gpio1 4 PWM_POLARITY_INVERTED&amp;gt;,
                    &amp;lt;&amp;amp;gpio1 5 PWM_POLARITY_INVERTED&amp;gt;,
                    &amp;lt;&amp;amp;gpio1 6 PWM_POLARITY_INVERTED&amp;gt;;
};

pwmleds {
    compatible = &amp;quot;pwm-leds&amp;quot;;
    pwm_green: pwm_led_0 {
        pwms = &amp;lt;&amp;amp;sw_pwm 0 PWM_MSEC(20) PWM_POLARITY_INVERTED&amp;gt;;
    };
    pwm_blue: pwm_led_1 {
        pwms = &amp;lt;&amp;amp;sw_pwm 1 PWM_MSEC(20) PWM_POLARITY_INVERTED&amp;gt;;
    };
    pwm_red: pwm_led_2 {
        pwms = &amp;lt;&amp;amp;sw_pwm 2 PWM_MSEC(20) PWM_POLARITY_INVERTED&amp;gt;;
    };
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;could you help me to solve this problem.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you can, please tell me why I need to use the `sw_pwm`?&lt;/p&gt;
&lt;p&gt;Because, In previous SDK version, the pwm works well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware PWM doesn't operate with 100% duty cycle</title><link>https://devzone.nordicsemi.com/thread/563194?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2026 09:59:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ee537f3-7a3d-420e-a5d9-b713a17ff605</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As per the code, if you check further down in the same function that you copied code from, it will disable the pwm module, and use nrf_gpio to set it to a&amp;nbsp;high or low level, based on if you input 100% or 0 % duty cycle.&lt;/p&gt;
&lt;p&gt;Here is a quick test, based on zephyr/samples/basic/blink_pwm:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2016 Intel Corporation
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @file Sample app to demonstrate PWM.
 */

#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/sys/printk.h&amp;gt;
#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/drivers/pwm.h&amp;gt;

static const struct pwm_dt_spec pwm_led0 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0));

#define MIN_PERIOD PWM_SEC(1U) / 128U
#define MAX_PERIOD PWM_SEC(1U)

int main(void)
{
	uint32_t max_period;
	uint32_t period;
	uint8_t dir = 0U;
	int ret;

	printk(&amp;quot;PWM-based blinky\n&amp;quot;);

	if (!pwm_is_ready_dt(&amp;amp;pwm_led0)) {
		printk(&amp;quot;Error: PWM device %s is not ready\n&amp;quot;,
		       pwm_led0.dev-&amp;gt;name);
		return 0;
	}

	/*
	 * In case the default MAX_PERIOD value cannot be set for
	 * some PWM hardware, decrease its value until it can.
	 *
	 * Keep its value at least MIN_PERIOD * 4 to make sure
	 * the sample changes frequency at least once.
	 */
	printk(&amp;quot;Calibrating for channel %d...\n&amp;quot;, pwm_led0.channel);
	max_period = MAX_PERIOD;
	while (pwm_set_dt(&amp;amp;pwm_led0, max_period, max_period / 2U)) {
		max_period /= 2U;
		if (max_period &amp;lt; (4U * MIN_PERIOD)) {
			printk(&amp;quot;Error: PWM device &amp;quot;
			       &amp;quot;does not support a period at least %lu\n&amp;quot;,
			       4U * MIN_PERIOD);
			return 0;
		}
	}

	printk(&amp;quot;Done calibrating; maximum/minimum periods %u/%lu nsec\n&amp;quot;,
	       max_period, MIN_PERIOD);

	period = max_period;
	while (1) {
		/* Set 100% for 1 sec */
		ret = pwm_set_dt(&amp;amp;pwm_led0, period, period);
		if (ret) {
			printk(&amp;quot;ret: %d\n&amp;quot;, ret);
		}
		k_sleep(K_SECONDS(1U));
		/* 50 % for 2 sec */
		ret = pwm_set_dt(&amp;amp;pwm_led0, period, period / 2U);
		if (ret) {
			printk(&amp;quot;ret: %d\n&amp;quot;, ret);
		}
		k_sleep(K_SECONDS(2U));
		/* 0 % for 4 sec */
		ret = pwm_set_dt(&amp;amp;pwm_led0, period, 0);
		if (ret) {
			printk(&amp;quot;ret: %d\n&amp;quot;, ret);
		}
		k_sleep(K_SECONDS(4U));
	}
	return 0;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Which behaves like this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1773395881837v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>