<?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>Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/121515/issue-about-pwm-of-ncs</link><description>Dear Nordic Engineers 
 I developed a PWM function to drive the RGB LED. Then I found a problem, which is w hen I used a PWM signal of one channel to control the RED light of the RGB lamp, causing it to go from bright to off and then back to bright, the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 20 Jun 2025 06:33:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/121515/issue-about-pwm-of-ncs" /><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/539954?ContentTypeID=1</link><pubDate>Fri, 20 Jun 2025 06:33:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df1f8775-cdf7-452d-affa-7b495f8bcb44</guid><dc:creator>Hannibalhz</dc:creator><description>&lt;p&gt;Hi Susheel&lt;/p&gt;
&lt;p&gt;I would like to know this&amp;nbsp;problem has any update?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hannibal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/537285?ContentTypeID=1</link><pubDate>Wed, 28 May 2025 06:27:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04008be4-58b9-4886-bb15-73765530856f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Yes, Hannibal, I meant to use three PWMs for testing. And it seemed&amp;nbsp; like your device tree looks right.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/536907?ContentTypeID=1</link><pubDate>Mon, 26 May 2025 10:50:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:909421eb-5d9c-4006-9dad-1d1fa33f419e</guid><dc:creator>Hannibalhz</dc:creator><description>&lt;p&gt;Hi Susheel&lt;/p&gt;
&lt;p&gt;Thank you for your best supports.&amp;nbsp;Do you mean using three PWMs? Then, do you think this way of writing the device tree is correct?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
    aliases {
        led0 = &amp;amp;led0;
		led1 = &amp;amp;led1;
		led2 = &amp;amp;led2;
        red-pwm-led   = &amp;amp;led_r;
        green-pwm-led = &amp;amp;led_g;
        blue-pwm-led  = &amp;amp;led_b;
    };

    leds {
		compatible = &amp;quot;gpio-leds&amp;quot;;
        led0: led_0 {
			gpios = &amp;lt;&amp;amp;gpio1 4 GPIO_ACTIVE_HIGH&amp;gt;;
			label = &amp;quot;Red LED 0&amp;quot;;
		};
		led1: led_1 {
			gpios = &amp;lt;&amp;amp;gpio1 5 GPIO_ACTIVE_HIGH&amp;gt;;
			label = &amp;quot;Green LED 1&amp;quot;;
		};
		led2: led_2 {
			gpios = &amp;lt;&amp;amp;gpio1 6 GPIO_ACTIVE_HIGH&amp;gt;;
			label = &amp;quot;Blue LED 2&amp;quot;;
		};
	};

    pwmleds {
        compatible = &amp;quot;pwm-leds&amp;quot;;
        
        led_r: led_0 {
            pwms = &amp;lt;&amp;amp;pwm20 0 PWM_MSEC(20) PWM_POLARITY_NORMAL&amp;gt;;
            label = &amp;quot;Red LED&amp;quot;;
        };
    
        led_g: led_1 {
            pwms = &amp;lt;&amp;amp;pwm21 0 PWM_MSEC(20) PWM_POLARITY_NORMAL&amp;gt;;
            label = &amp;quot;Green LED&amp;quot;;
        };
    
        led_b: led_2 {
            pwms = &amp;lt;&amp;amp;pwm22 0 PWM_MSEC(20) PWM_POLARITY_NORMAL&amp;gt;;
            label = &amp;quot;Blue LED&amp;quot;;
        };
    };
};

&amp;amp;pwm20 {
    status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;pwm20_default&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;pwm20_sleep&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;pwm21 {
    status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;pwm21_default&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;pwm21_sleep&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;pwm22 {
    status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;pwm22_default&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;pwm22_sleep&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};


&amp;amp;pinctrl {
    pwm20_default: pwm20_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(PWM_OUT0, 1, 4)&amp;gt;;   /* P1.04 -&amp;gt; LED_R */
        };
    };
    pwm20_sleep: pwm20_sleep {
        group1 {
            psels = &amp;lt;NRF_PSEL(PWM_OUT0, 1, 4)&amp;gt;;   /* P1.04 -&amp;gt; LED_R */
                    low-power-enable;
        };
    };

    pwm21_default: pwm21_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(PWM_OUT0, 1, 5)&amp;gt;;   /* P1.05 -&amp;gt; LED_G */
        };
    };
    pwm21_sleep: pwm21_sleep {
        group1 {
            psels = &amp;lt;NRF_PSEL(PWM_OUT0, 1, 5)&amp;gt;;   /* P1.05 -&amp;gt; LED_G */
                    low-power-enable;
        };
    };

    pwm22_default: pwm22_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(PWM_OUT0, 1, 6)&amp;gt;;   /* P1.06 -&amp;gt; LED_B */
        };
    };
    pwm22_sleep: pwm22_sleep {
        group1 {
            psels = &amp;lt;NRF_PSEL(PWM_OUT0, 1, 6)&amp;gt;;   /* P1.06 -&amp;gt; LED_B */
                    low-power-enable;
        };
    };
};




&amp;amp;uart20 {
    status = &amp;quot;disabled&amp;quot;;
};

&amp;amp;uart30 {
    status = &amp;quot;okay&amp;quot;;
};
/{
    chosen {
        zephyr,console = &amp;amp;uart30;
        zephyr,shell-uart = &amp;amp;uart30;
        zephyr,uart-mcumgr = &amp;amp;uart30;
        zephyr,bt-mon-uart = &amp;amp;uart30;
        zephyr,bt-c2h-uart = &amp;amp;uart30;
    };
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hannibal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/536343?ContentTypeID=1</link><pubDate>Wed, 21 May 2025 08:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2370c819-b307-4f20-8c8f-1ac7da1c858a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Hannibal,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It is possible that there is a bug in PWM driver in this scenario. The thing is that this is only reproduced on nRF54 and I am unable to see such issues on nRF52. I need to spend more time on it and probably create an internal ticket to debug it to the hardware level. This might take time. But until then can you please try to see if you can change your firmware and devicetree to use three different pwm instances for three LEDs?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/536193?ContentTypeID=1</link><pubDate>Tue, 20 May 2025 12:06:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eac67e2e-9c33-405b-a533-96c1f9652a28</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Hannibal,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried to debug this and use a lot of different ways to initialize the PWM and also use&amp;nbsp;pwm_set_pulse_dt individually to set PWM but I can still see the other channels being impacted whenever we start or stop the PWM (brightness level 0-&amp;gt;1 or 1-&amp;gt;0). I need to spend more time to debug this.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/536073?ContentTypeID=1</link><pubDate>Tue, 20 May 2025 06:15:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecbf5830-0615-4342-9ecc-9097290a3415</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Hannibal,&lt;/p&gt;
&lt;p&gt;I reproduced the behavior and trying to debug it now. Will come back to you once I have some progress and new info to share with you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/535901?ContentTypeID=1</link><pubDate>Mon, 19 May 2025 05:43:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08e6e49c-8c64-42a1-84fa-1b2ab8dff715</guid><dc:creator>Hannibalhz</dc:creator><description>&lt;p&gt;Hi Susheel&lt;/p&gt;
&lt;p&gt;According to the latest test I conducted, this issue has nothing to do with the LED numbers. Because even after I changed it to this way, where only one channel is controlled, the problem still persists.&lt;pre class="ui-code" data-mode="text"&gt;int main(void)
{
	const struct device *led_pwm;
	uint8_t led;

	led_pwm = DEVICE_DT_GET(LED_PWM_NODE_ID);
	if (!device_is_ready(led_pwm)) {
		LOG_ERR(&amp;quot;Device %s is not ready&amp;quot;, led_pwm-&amp;gt;name);
		return 0;
	}

	if (!num_leds) {
		LOG_ERR(&amp;quot;No LEDs found for %s&amp;quot;, led_pwm-&amp;gt;name);
		return 0;
	}

	while (1)
	{
			run_led_test(led_pwm, 0);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can use my code to conduct a test on the NRF54L15DK. Using a logic analyzer, it is quite easy to reproduce this problem.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hannibal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/535697?ContentTypeID=1</link><pubDate>Fri, 16 May 2025 06:41:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfee311e-0d7f-4402-8cbc-e8727c906f2c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Wang,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think the whole issue here is that you are&amp;nbsp;executing&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;	while (1)
	{
		// for (led = 1; led &amp;lt;= num_leds; led++) {
			run_led_test(led_pwm, 3);
		// }
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;LED here is not just a number but it is the PWM channel index as specified in your overlay file like below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    pwms = &amp;lt;&amp;amp;pwm20 0 …&amp;gt;,   /* led index 0: RED  */
           &amp;lt;&amp;amp;pwm20 1 …&amp;gt;,   /* led index 1: GREEN*/
           &amp;lt;&amp;amp;pwm20 2 …&amp;gt;;   /* led index 2: BLUE */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So in the configuration&amp;nbsp;config-&amp;gt;num_leds == 3 which you have used right but the indices are&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;led_set_brightness(led_pwm, 0, brightness);  // RED
led_set_brightness(led_pwm, 1, brightness);  // GREEN
led_set_brightness(led_pwm, 2, brightness);  // BLUE
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So your for loop should not start at led = 1 but should start at led =0&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;for (uint8_t led = 0; led &amp;lt; num_leds; led++) {
    run_led_test(led_pwm, led);
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue about PWM of NCS</title><link>https://devzone.nordicsemi.com/thread/535683?ContentTypeID=1</link><pubDate>Fri, 16 May 2025 04:01:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5db95e0b-8047-4cd1-982d-ebb9602294b4</guid><dc:creator>Hannibalhz</dc:creator><description>&lt;p&gt;update:&lt;/p&gt;
&lt;p&gt;Today, I debugged and found that only the register configuration of one channel was set. However, the levels of the other two channels were actually flipped. Moreover, this phenomenon does not occur when using three channels; it only happens when using a single channel.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:221px;max-width:713px;" height="221" src="https://devzone.nordicsemi.com/resized-image/__size/1426x442/__key/communityserver-discussions-components-files/4/pastedimage1747367912755v1.jpeg" width="713" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>