<?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 Save GPIO output status after reset</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109534/zephyr-save-gpio-output-status-after-reset</link><description>Hi All, 
 I am using a nrf52840 chip with Zephyr OS. I wanted to know if there is a way to save the status of a GPIO output pin after a reset (caused by the Watchdog timer). 
 I found the initialization GPIO API: 
 
 And passing as flag: “GPIO_OUTPUT</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Mar 2024 14:16:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109534/zephyr-save-gpio-output-status-after-reset" /><item><title>RE: Zephyr Save GPIO output status after reset</title><link>https://devzone.nordicsemi.com/thread/475419?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2024 14:16:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4172ca9e-aeab-46c8-bf8b-0242e3feda4d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Sorry, you&amp;#39;re right. I forgot the retained registers are cleared through WD resets. Writing to flash is also problematic because you only have 2 32K cycles to perform the write:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;If the watchdog is configured to generate an interrupt on the TIMEOUT event, the watchdog reset will be postponed with two 32.768 kHz clock cycles after the TIMEOUT event has been generated. Once the TIMEOUT event has been generated, the impending watchdog reset will always be effectuated.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a title="Watchdog reset" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/wdt.html?cp=5_0_0_5_35_2#concept_b4n_xzw_sr"&gt;Watchdog reset&lt;/a&gt;&amp;nbsp;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The best option is likely to use the&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.6.0/zephyr/services/retention/index.html"&gt;Retention System&lt;/a&gt;&amp;nbsp;which allocates a non-init section in RAM. Please note that the spec. does not guarantee that RAM will be retained through a WD reset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr Save GPIO output status after reset</title><link>https://devzone.nordicsemi.com/thread/475414?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2024 14:03:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9fad0f7-8336-48ed-b053-4e1d6d2f1858</guid><dc:creator>LucaMar</dc:creator><description>&lt;p&gt;ok for NV memory, but for GPREGRET I am seeing that a WD reset will clear and reset the value, does it?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1711116205109v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr Save GPIO output status after reset</title><link>https://devzone.nordicsemi.com/thread/475351?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2024 10:18:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5c261f3-936f-4e0f-b71e-cdb020119c20</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Yes, that will require use of NV memory, or&amp;nbsp;&lt;a title="GPREGRET" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=5_0_0_4_2_6_15#register.GPREGRET"&gt;GPREGRET&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr Save GPIO output status after reset</title><link>https://devzone.nordicsemi.com/thread/475341?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2024 09:45:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61f856fc-86ed-421e-9f5d-30e6d6074ddc</guid><dc:creator>LucaMar</dc:creator><description>&lt;p&gt;I wanted to retain the GPIO output status after a reset occurs so that after reset it will recover it&amp;#39;s status, and I thought a solution &amp;quot;confined&amp;quot; to the GPIO peripheral without involving any non-volatile memory. But at this point I don&amp;#39;t know if it is possible&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr Save GPIO output status after reset</title><link>https://devzone.nordicsemi.com/thread/475306?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2024 08:09:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cea1ab92-986f-4625-ba3e-f2dbd35c922e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It is not possible to retain the GPIO configurations through a WD reset. The reset will reconfigure all pins to their default state.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1711094678552v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a title="Reset behavior" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=5_0_0_4_2_5_7#concept_res_behav"&gt;Reset behavior&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Default reset state:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1711094742377v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/gpio.html?cp=5_0_0_5_8_1_9#register.PIN_CNF-0-31"&gt;PIN_CNF[n]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I may be able to suggest another approach if you could provide a bit more information about the use case and what you are trying to achieve.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr Save GPIO output status after reset</title><link>https://devzone.nordicsemi.com/thread/475191?ContentTypeID=1</link><pubDate>Thu, 21 Mar 2024 15:06:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bcc3791-53ee-4ed0-84c8-e0ebbb647ca2</guid><dc:creator>LucaMar</dc:creator><description>&lt;p&gt;I missed to say that before resetting I put the GPIO status to one of the two logic status, example of operations:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. Init GPIO with&amp;nbsp;gpio_pin_configure_dt and &amp;quot;GPIO_OUTPUT&amp;quot; flag;&lt;/p&gt;
&lt;p&gt;2. force GPIO status to &amp;quot;1&amp;quot;&lt;/p&gt;
&lt;p&gt;3. reset by watchdog (or button reset)&lt;/p&gt;
&lt;p&gt;4. The GPIO status changed it&amp;#39;s value to &amp;quot;0&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>