<?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>PWM on nRF52840 GPIO with Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71634/pwm-on-nrf52840-gpio-with-zephyr</link><description>Hello, guys. 
 We are have nRF52840DK board and Zephyr NCS 1.4.2 development environment. 
 I am trying to include two PWM channels in the code and control them independently through Zephyr PWM drivers and pwm_pin_set_usec() function. 
 Everything seems</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 16 Feb 2021 11:40:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71634/pwm-on-nrf52840-gpio-with-zephyr" /><item><title>RE: PWM on nRF52840 GPIO with Zephyr</title><link>https://devzone.nordicsemi.com/thread/294597?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 11:40:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f1047cd-ac7d-4700-99eb-04e40617ea74</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The zephyr pwm driver API has this restriction, as per its header docs:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1-rc1/include/drivers/pwm.h#L155-L158"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1-rc1/include/drivers/pwm.h#L155-L158&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="bojan"]Also, where is the place we define the polarity of the PWM signal?[/quote]
&lt;p&gt;&amp;nbsp;bit 0 in the flags you pass is the polarity:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1-rc1/include/drivers/pwm.h#L40"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.4.99-ncs1-rc1/include/drivers/pwm.h#L40&lt;/a&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><item><title>RE: PWM on nRF52840 GPIO with Zephyr</title><link>https://devzone.nordicsemi.com/thread/294568?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 10:32:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f77db653-386a-438a-8b7f-11369c1ce17f</guid><dc:creator>bojan</dc:creator><description>&lt;p&gt;Hello, Hakon...&lt;/p&gt;
&lt;p&gt;I still have a hard time to properly use Zephyr PWM driver.&lt;/p&gt;
&lt;p&gt;According to some threads (&lt;a href="https://medium.com/home-wireless/using-a-pwm-device-in-zephyr-7100d089f15c" rel="noopener noreferrer" target="_blank"&gt;link&lt;/a&gt;), in order to stop playing PWM pattern on GPIO, we need to set the pulse width parameter to 0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;pwm_pin_set_usec(pwm_dev, PWM_CHANNEL, period_us, 0)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;However, here is what I get on GPIO when I want to stop PWM (Channel D0):&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7462.Screenshot_5F00_3.png" /&gt;&lt;/p&gt;
&lt;p&gt;What is the proper way of stop playing PWM pattern on GPIO? Also, where is the place we define the polarity of the PWM signal?&lt;/p&gt;
&lt;p&gt;Thanks in advance. Looking forward to reading from you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Sincerely,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM on nRF52840 GPIO with Zephyr</title><link>https://devzone.nordicsemi.com/thread/294557?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 09:02:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94bf303b-7cfa-4792-98e7-66bb5d095787</guid><dc:creator>bojan</dc:creator><description>&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM on nRF52840 GPIO with Zephyr</title><link>https://devzone.nordicsemi.com/thread/294393?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 13:28:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47ac83ee-2acf-4f3c-add4-d0464d297eb2</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;
[quote user=""]As I said, PWMs are working only for GPIOs 13, 14, 15, and 16. When I set &lt;strong&gt;GPIO 0&lt;/strong&gt; for &lt;em&gt;&lt;strong&gt;&amp;amp;pwm0&lt;/strong&gt;&lt;/em&gt;, for example, we don&amp;#39;t get PWM signal on P0.0 output.[/quote]
&lt;p&gt;If you use the external 32k clock, P0.00 and P0.01 is already in use by the LFCLK. If you do not have or plan to use the external LFCLK, you can switch the source to RC for instance, by setting this configuration:&lt;/p&gt;
&lt;p&gt;CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y&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>