<?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>Adding PWM Channels in Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/95405/adding-pwm-channels-in-zephyr</link><description>I am developing a custom board application in Zephyr 3.2.99. I have a single PWM Channel running now but having trouble adding addtional channels. 
 
 In the 52811.dtsi, I have a single pwm node: 
 
 then, in my pinctrl-dtsi I have: 
 
 The in my .dts</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 10 Jan 2023 08:58:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/95405/adding-pwm-channels-in-zephyr" /><item><title>RE: Adding PWM Channels in Zephyr</title><link>https://devzone.nordicsemi.com/thread/404005?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2023 08:58:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:956fa1b2-913c-42b2-95bf-1db1dc5f36bb</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Glad I could help Drew. The best of luck with your project &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding PWM Channels in Zephyr</title><link>https://devzone.nordicsemi.com/thread/403913?ContentTypeID=1</link><pubDate>Mon, 09 Jan 2023 16:37:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3989bebd-f488-4da0-b512-36571eb24e5f</guid><dc:creator>MtnDrew</dc:creator><description>&lt;p&gt;That is very helpful. We don&amp;#39;t use overlays. All of our Zephyr implementions use custom BSP.&amp;nbsp; You may consider this issue closed.&amp;nbsp; Thank you all for your support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding PWM Channels in Zephyr</title><link>https://devzone.nordicsemi.com/thread/403762?ContentTypeID=1</link><pubDate>Mon, 09 Jan 2023 09:04:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d61b8976-5a55-4fa8-b365-1390918c49af</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Drew&lt;/p&gt;
&lt;p&gt;Yes,&amp;nbsp;you can just remove this property from the overlay.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the long run you might want to create your own custom board implementation rather than using an overlay, then you can set this properly in the board files directly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding PWM Channels in Zephyr</title><link>https://devzone.nordicsemi.com/thread/403644?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2023 16:38:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65b1c6cb-dda5-4238-a6c2-4f2066568447</guid><dc:creator>MtnDrew</dc:creator><description>&lt;p&gt;Thanks for the reply. I figured that out shortly after I posted. The problem was that I had the pwmleds configured as the default PWM_POLARITY_INVERTED. So the led&amp;#39;s would turn on as soon as the board started.&amp;nbsp; I switched to PWM_POLARITY_NORMAL and now everything is behaving as we desire.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	pwm0_default: pwm0_default {
		// Channel 0
		group1 {
			psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0, 23)&amp;gt;, // Channel 0 
					&amp;lt;NRF_PSEL(PWM_OUT1, 0, 15)&amp;gt;, // Channel 1
					&amp;lt;NRF_PSEL(PWM_OUT2, 0, 22)&amp;gt;; // Channel 2

			//nordic,invert;
		};

	};

	pwmleds {
		compatible = &amp;quot;pwm-leds&amp;quot;;
			// pwm0 Ch 0
			pwm_led0: pwm_led_0 { 
					//pwms = &amp;lt;&amp;amp;pwm0 0 PWM_NSEC(62500) PWM_POLARITY_INVERTED&amp;gt;;
					pwms = &amp;lt;&amp;amp;pwm0 0 PWM_NSEC(62500) PWM_POLARITY_NORMAL&amp;gt;;
			};
			// pwm0 Ch 1
			pwm_led1: pwm_led_1 { 
					pwms = &amp;lt;&amp;amp;pwm0 1 PWM_NSEC(62500) PWM_POLARITY_NORMAL&amp;gt;;

			};
			// pwm0 Ch 2
			pwm_led2: pwm_led_2 {
					pwms = &amp;lt;&amp;amp;pwm0 2 PWM_NSEC(62500) PWM_POLARITY_NORMAL&amp;gt;;
			};
	
	};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I simply commented out the &amp;quot;nordic,invert&amp;quot; property in the pinctrl-dtsi but I&amp;#39;m not sure if that is the proper way to handle that.&lt;/p&gt;
&lt;p&gt;Drew&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding PWM Channels in Zephyr</title><link>https://devzone.nordicsemi.com/thread/403590?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2023 13:14:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:202f4d55-e36c-49ca-b3a3-26a6b83077af</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Drew&lt;/p&gt;
&lt;p&gt;I think the problem is that you haven&amp;#39;t properly added the additional channels to the pinctrl and pwmleds nodes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was able to add a second channel to the led_pwm sample in Zephyr simply by adding the following overlay file to the example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {
    pwm0_default: pwm0_default {
		group1 {
			psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0, 13)&amp;gt;,
                    &amp;lt;NRF_PSEL(PWM_OUT1, 0, 14)&amp;gt;;
			nordic,invert;
		};
	};

	pwm0_sleep: pwm0_sleep {
		group1 {
			psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0, 13)&amp;gt;,
                    &amp;lt;NRF_PSEL(PWM_OUT1, 0, 14)&amp;gt;;
			low-power-enable;
		};
	};
};

/{
	pwmleds {
		compatible = &amp;quot;pwm-leds&amp;quot;;
		pwm_led0: pwm_led_0 {
			pwms = &amp;lt;&amp;amp;pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED&amp;gt;;
		};
        pwm_led1: pwm_led_1 {
			pwms = &amp;lt;&amp;amp;pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED&amp;gt;;
		};
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please note I used a nRF52840DK for the test, but the code should look similar for the nRF52811.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>