<?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>nRF52820 PWM Device Tree / API</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99780/nrf52820-pwm-device-tree-api</link><description>I am new to Zephyr/nRF environemnt and using the nRF52833-DK to emulate nRF52820 which does not have any dedicated PWM hardware From my understanding I am limited to the software PWM API from nRF Connect SDK (using v2.3.0) - nordic,nrf-sw-pwm 
 
 I am</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 May 2023 15:35:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99780/nrf52820-pwm-device-tree-api" /><item><title>RE: nRF52820 PWM Device Tree / API</title><link>https://devzone.nordicsemi.com/thread/426084?ContentTypeID=1</link><pubDate>Wed, 17 May 2023 15:35:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:530a60ac-1dbc-4b3b-ab2e-ec9fdef8a2f1</guid><dc:creator>CCL-KH</dc:creator><description>&lt;p&gt;Thank you for your support&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52820 PWM Device Tree / API</title><link>https://devzone.nordicsemi.com/thread/426078?ContentTypeID=1</link><pubDate>Wed, 17 May 2023 15:16:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ac9d21a-40e3-48bf-88a9-897c5efeb47a</guid><dc:creator>khelmutlord</dc:creator><description>&lt;p&gt;Apologies. Upon further investigation, it seems that only one software PWM instance is supported at a time.&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/pwm/pwm_nrf5_sw.c"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/pwm/pwm_nrf5_sw.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There is a possible solution that my require modifying some files within the Zephyr SDK.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/42b121ee9519d5bb96c6e6197733aa204d99486e/dts/bindings/pwm/nordic%2Cnrf-sw-pwm.yaml#L3"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/42b121ee9519d5bb96c6e6197733aa204d99486e/dts/bindings/pwm/nordic%2Cnrf-sw-pwm.yaml#L3&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the device tree bindings, it makes clear that the number of PWM channels supported is the number of timer compare registers minus 1. For the nRF52820, that is 3 total for timer[0-2]. However, timer3 has 6 compare registers so would support 5 PWM channels.&lt;/p&gt;
&lt;p&gt;&lt;span id="pastedimage1684336522555v2" class="mceItem mceNonEditable mceInsertMediaItem mceInsertMediaItem mceInsertMediaItemImage" style="color:transparent;height:240px;width:320px;"&gt;...&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To make this change, modify the example to use timer3 for the generator, modify the device tree bindings in the Zephyr SDK to support up to 5 PWM cells, and set #pwm-cells to 5.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52820 PWM Device Tree / API</title><link>https://devzone.nordicsemi.com/thread/426077?ContentTypeID=1</link><pubDate>Wed, 17 May 2023 14:49:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be52e490-4026-4e86-b19e-05dd4a5ae90c</guid><dc:creator>CCL-KH</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for your support&lt;br /&gt;&lt;br /&gt;I was able to build the project &amp;#39;as is&amp;#39; however I think you have a typo&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;line 25: pwm_dev1 = DEVICE_DT_GET(PWM_NODE_LABEL);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;should be&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;line 25: pwm_dev1 = DEVICE_DT_GET(PWM_NODE_LABEL_1);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;which fails build with:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1684334992790v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52820 PWM Device Tree / API</title><link>https://devzone.nordicsemi.com/thread/426075?ContentTypeID=1</link><pubDate>Wed, 17 May 2023 14:41:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a264c1a-9e1e-40c5-994d-a7258720b481</guid><dc:creator>khelmutlord</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I was able to get two software PWM instances to compile with the following DeviceTree overlay. Key thing is that the overlay file is named &amp;quot;nrf52833dk_nrf52820.overlay&amp;quot;&lt;/p&gt;
&lt;p&gt;You will find this in the attached project.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/led_5F00_pwm_5F00_5_5F00_17_5F00_2023.zip"&gt;devzone.nordicsemi.com/.../led_5F00_pwm_5F00_5_5F00_17_5F00_2023.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Helmut Lord&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52820 PWM Device Tree / API</title><link>https://devzone.nordicsemi.com/thread/425900?ContentTypeID=1</link><pubDate>Tue, 16 May 2023 13:57:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9fa4733-bc79-402a-9813-9b993c7c0c5c</guid><dc:creator>CCL-KH</dc:creator><description>&lt;p&gt;Thank you for you help, I have now successfully implemented all 3 pwm channels via the &lt;span&gt;single sw-pwm instance&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;I am experimenting adding more&amp;nbsp;sw-pwm instances (I believe each requires 1&amp;nbsp;generator and X PPI channels). I am hitting compilation errors. In the code below &amp;#39;sw-pwm&amp;#39; is defined in&amp;nbsp;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;lt;nordic/nrf52820_qdaa.dtsi&amp;gt; however I am leaving that &amp;#39;status=disabled&amp;#39; and creating 2 new nodes: &amp;#39;sw_pwm0: sw-pwm0&amp;#39; &amp;amp;&amp;nbsp;&amp;#39;sw_pwm1: sw-pwm1&amp;#39; that are compatible with &amp;#39;nordic,nrf-sw-pwm&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/dts-v1/;
#include &amp;lt;nordic/nrf52820_qdaa.dtsi&amp;gt;

/ {
	sw_pwm1: sw-pwm1 {
		compatible = &amp;quot;nordic,nrf-sw-pwm&amp;quot;;
    	status =&amp;quot;okay&amp;quot;;
    	channel-gpios = &amp;lt;&amp;amp;gpio0 14 GPIO_ACTIVE_LOW&amp;gt;,
    					&amp;lt;&amp;amp;gpio0 15 GPIO_ACTIVE_LOW&amp;gt;;
    	clock-prescaler = &amp;lt;0&amp;gt;;
    	generator = &amp;lt;&amp;amp;timer2&amp;gt;;
		#pwm-cells = &amp;lt;3&amp;gt;;
	};

	sw_pwm0: sw-pwm0 {
		compatible = &amp;quot;nordic,nrf-sw-pwm&amp;quot;;
    	status =&amp;quot;okay&amp;quot;;
    	channel-gpios = &amp;lt;&amp;amp;gpio0 16 GPIO_ACTIVE_LOW&amp;gt;;
    	clock-prescaler = &amp;lt;0&amp;gt;;
    	generator = &amp;lt;&amp;amp;timer1&amp;gt;;
		#pwm-cells = &amp;lt;3&amp;gt;;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;pwm_init()&lt;pre class="ui-code" data-mode="text"&gt;	const struct device *driver0;
	driver0 = DEVICE_DT_GET(DT_NODELABEL(sw_pwm0));
	pwm_set_cycles(driver0, 0, CONFIG_SYS_CLOCK_TICKS_PER_SEC, CONFIG_SYS_CLOCK_TICKS_PER_SEC / 8, PWM_POLARITY_INVERTED);

	const struct device *driver1;
	driver1 = DEVICE_DT_GET(DT_NODELABEL(sw_pwm1));
    pwm_set_cycles(driver1, 0, CONFIG_SYS_CLOCK_TICKS_PER_SEC, CONFIG_SYS_CLOCK_TICKS_PER_SEC, PWM_POLARITY_INVERTED);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;compile error:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1684245547173v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52820 PWM Device Tree / API</title><link>https://devzone.nordicsemi.com/thread/425707?ContentTypeID=1</link><pubDate>Mon, 15 May 2023 17:34:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dddde88d-4fca-4c5d-8a3c-55e585f123f9</guid><dc:creator>khelmutlord</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have attached an example project that shows how to use software PWM to blink an LED (directly! not through the LED library). It is set up to be used for an nRF52840-DK because that I don&amp;#39;t have a 52833-DK handy but you should be able to just rename the board overlay file that I included.&lt;/p&gt;
&lt;p&gt;I included a comment w/ a link to the nRF5 SW-PWM implementation for more information.&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/pwm/pwm_nrf5_sw.c"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/pwm/pwm_nrf5_sw.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/led_5F00_pwm.zip"&gt;devzone.nordicsemi.com/.../led_5F00_pwm.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Helmut Lord&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>