<?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>Zephyr PWM and GPIO in System Off</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94910/zephyr-pwm-and-gpio-in-system-off</link><description>Hi, 
 I am developing on a nRF52840dk. I control a LED2 (line P0.14) with PWM in normal operation and want to leave the LED2 ON when I go to System Off mode. 
 I tried setting the line to constant active with the Zephyr PWM driver by setting the pulse</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Dec 2022 16:58:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94910/zephyr-pwm-and-gpio-in-system-off" /><item><title>RE: Zephyr PWM and GPIO in System Off</title><link>https://devzone.nordicsemi.com/thread/401109?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2022 16:58:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:561c3eae-4ce0-4ce2-a42a-0d3902c285b2</guid><dc:creator>Airat</dc:creator><description>&lt;p&gt;Thank you, that did what I wanted.&lt;/p&gt;
&lt;p&gt;To note GPIO must be configured to output after locking the PWM device, as it sets the PIN_CNF to the default state (0x20).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Off</title><link>https://devzone.nordicsemi.com/thread/401098?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2022 15:48:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62f826d4-c1ba-46bc-92c2-13149f8655ae</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Looks like it&amp;#39;s the device driver Power Management implementation that sets the pin to this state as part of the process of going into System Off mode. I haven&amp;#39;t tested it, but something like this might work to avoid that:&lt;/p&gt;
&lt;p&gt;1) ret = pm_device_action_run(pwm, PM_DEVICE_ACTION_SUSPEND); // unit the PWM&lt;br /&gt;2) ret = pm_device_state_lock(pwm); // Lock the PWM DEVICE&lt;/p&gt;
&lt;p&gt;3) Use GPIO API to set the pin as you like&lt;/p&gt;
&lt;p&gt;4) Enter system off mode&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Off</title><link>https://devzone.nordicsemi.com/thread/401073?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2022 13:31:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2922c4d1-7113-4b29-8279-e1cecc512e20</guid><dc:creator>Airat</dc:creator><description>&lt;p&gt;Yes, exactly. I need an option for choosing LED to be on or off in System Off mode in a run-time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Off</title><link>https://devzone.nordicsemi.com/thread/401072?ContentTypeID=1</link><pubDate>Fri, 16 Dec 2022 13:29:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3ad0b70-75a9-41bc-ae4f-7ad242facb47</guid><dc:creator>Sigurd</dc:creator><description>[quote user="Airat"]&lt;p&gt;Interestingly, if I add&amp;nbsp;&lt;span&gt;nordic,invert&lt;/span&gt;&lt;span&gt;&lt;span&gt;; to&amp;nbsp;&lt;/span&gt;&lt;/span&gt;pwm0_sleep then the LED is always off in System Off mode.&lt;/p&gt;
&lt;p&gt;Is there a way to control that behavior just before going to System Off? Or will I need to drop usage of the Zephyr PWM driver?&amp;nbsp;&amp;nbsp;&lt;/p&gt;[/quote]
&lt;p&gt;So it&amp;#39;s not enough to set the desired level with/without&amp;nbsp;&lt;span&gt;nordic,invert&lt;/span&gt;&lt;span&gt;; to&amp;nbsp;&lt;/span&gt;&lt;span&gt;pwm0_sleep ? You want to change it based on something at run-time?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Off</title><link>https://devzone.nordicsemi.com/thread/400959?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 21:21:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7262d40-d8d1-4931-a6ee-c86387031a12</guid><dc:creator>Airat</dc:creator><description>&lt;p&gt;Including PWM driver by CONFIG_PWM=y seems to force the GPIO pin to be configured to OUTPUT with low level (regardless if it&amp;#39;s active high or low). And it matches with the requirements from documentation on the PWM peripheral&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fpwm.html&amp;amp;cp=4_0_0_5_16_3&amp;amp;anchor=concept_ckf_5qw_nr"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fpwm.html&amp;amp;cp=4_0_0_5_16_3&amp;amp;anchor=concept_ckf_5qw_nr&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;It looks like the device sets the GPIO pin to 0 before going to System Off.&lt;/p&gt;
&lt;p&gt;Interestingly, if I add&amp;nbsp;&lt;span&gt;nordic,invert&lt;/span&gt;&lt;span&gt;&lt;span&gt;; to&amp;nbsp;&lt;/span&gt;&lt;/span&gt;pwm0_sleep then the LED is always off in System Off mode.&lt;/p&gt;
&lt;p&gt;Is there a way to control that behavior just before going to System Off? Or will I need to drop usage of the Zephyr PWM driver?&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Of</title><link>https://devzone.nordicsemi.com/thread/400947?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 19:27:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60644a65-c963-4667-a96e-6c6922a424c5</guid><dc:creator>Airat</dc:creator><description>&lt;p&gt;I have found a way to make it work.&lt;/p&gt;
&lt;p&gt;I have removed the&amp;nbsp;&lt;code&gt;low-power-enable;&lt;/code&gt; from the &lt;code&gt;pwm0_sleep&lt;/code&gt; pin configuration node. And I did not use gpio driver api to set constant active level on the pin. Setting the pulse equal to the period with pwm driver api sets the relevant gpio out to the active level.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;EDIT: Unfortunately, it is not completely solved. I cannot control whether GPIO pin should be active or inactive when the device goes to System Off. Regardless of the GPIO OUT values or previous PWM pulse configuration (to 0 or to period) the pin will be active in System Off.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Any advice on how to control it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Of</title><link>https://devzone.nordicsemi.com/thread/400894?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 14:56:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1678ca45-327a-4ceb-b681-4d20af615bde</guid><dc:creator>Airat</dc:creator><description>&lt;p&gt;I tried and it didn&amp;#39;t work. The LED still went off after going system off. And 1 is is still in the&amp;nbsp;&lt;span&gt;NRF_PWM0-&amp;gt;ENABLE.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The ways I found to keep the LED on in system off is to assign different pin for pwm0_sleep pinctrl, but it is not a viable option for my project, as I use all gpio pins and I don&amp;#39;t want to cause a problem with strange pin assignments.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Just to clarify, calling&amp;nbsp;gpio_pin_set_dt() does make LED go brighter, so constant level can be set with gpio api. But LED is not kept on in system off.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Of</title><link>https://devzone.nordicsemi.com/thread/400879?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 14:27:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1257780-c683-401a-a1d6-6ad87a27bec9</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Try setting&amp;nbsp;&lt;span&gt;NRF_PWM0-&amp;gt;PSEL.OUT[0] to&amp;nbsp;0xFFFFFFFF , before you configure the GPIO as output and set it to the desired level.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Of</title><link>https://devzone.nordicsemi.com/thread/400849?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 13:32:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14fd3e49-ceff-462e-9d71-ba37b44c7ab2</guid><dc:creator>Airat</dc:creator><description>&lt;p&gt;I can check register values before, and after setting the GPIO pin&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NRF_PWM0-&amp;gt;ENABLE: 0x00000001&lt;/code&gt;&lt;br /&gt;&lt;code&gt;NRF_PWM0-&amp;gt;PSEL.OUT[0]: 0x0000000E&lt;/code&gt;&lt;br /&gt;&lt;code&gt;NRF_GPIO-&amp;gt;PIN_CNF[14]: 0x00000003&lt;/code&gt;&lt;br /&gt;&lt;code&gt;NRF_GPIO-&amp;gt;OUTSET: 0x00004060&lt;/code&gt;&lt;br /&gt;&lt;code&gt;GPIO P0.14 set: 1&lt;/code&gt;&lt;br /&gt;&lt;code&gt;NRF_PWM0-&amp;gt;ENABLE: 0x00000001&lt;/code&gt;&lt;br /&gt;&lt;code&gt;NRF_PWM0-&amp;gt;PSEL.OUT[0]: 0x0000000E&lt;/code&gt;&lt;br /&gt;&lt;code&gt;NRF_GPIO-&amp;gt;PIN_CNF[14]: 0x00000003&lt;/code&gt;&lt;br /&gt;&lt;code&gt;NRF_GPIO-&amp;gt;OUTSET: 0x00000060&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Yes the GPIO pin 14 is set to active level.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr PWM and GPIO in System Of</title><link>https://devzone.nordicsemi.com/thread/400830?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 12:51:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bac5615-777b-4a7a-b7cf-c142e2082aac</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]I tried setting the line to constant inactive with the Zephyr PWM driver by setting the pulse equal to 0 and then setting the active level with the GPIO driver.[/quote]
&lt;p&gt;In this case,&amp;nbsp;did you check that the GPIO&amp;nbsp;was at the correct level before system off?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>