<?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>Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88311/multiple-gpio-interrupts-from-system_soft_off</link><description>OK, so it seems if you accidently hit &amp;quot;VERIFY ANSWER&amp;quot; your discussion gets locked and you can no longer comment, nor reverse that process. So, I&amp;#39;ve had to start a new discussion in order to keep on with the old one: 
 https://devzone.nordicsemi.com/f</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Dec 2022 09:15:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88311/multiple-gpio-interrupts-from-system_soft_off" /><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/400321?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 09:15:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:938082ee-68ae-4d38-b372-0684ac18317e</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Yes,, that was the approach I had to take.&lt;/p&gt;
&lt;p&gt;it was further complicated by the fact that I have mcuboot enabled (my code allows for an OTA DFU) and this was clearing my LATCH register before the Pre-kernel code could grab the value as you are doing.&lt;/p&gt;
&lt;p&gt;if you read the thread further down, you can see how I got around this (using the mcuboot.confi file with CONFIG_GPIO=N setting)&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/400300?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 08:07:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b88d77c2-718f-4e74-8fab-d5180662d251</guid><dc:creator>Airat</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;do you have any success in figuring out the reason for the reset LATCH register? We have the same problem with nRF52832 and&amp;nbsp;NCS 2.0.0 multiple wake up interrupts from different sources. I also managed to recreate the issue on mNR52840dk by clicking two buttons quickly one after another.&lt;br /&gt;&lt;br /&gt;The only work around that worked for us is to read the value of the LATCH register on the&amp;nbsp;PRE_KERNEL_2 level, save the value in some static variable and then process that value on the application level.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/374266?ContentTypeID=1</link><pubDate>Mon, 27 Jun 2022 07:16:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b148cc1-c617-4793-8260-79e31f8e7a30</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Yep - tried Hakon&amp;#39;s suggestion, which fixed that issue.&amp;nbsp; It did, unfortunately, knobble my retained RAM functionality.&amp;nbsp; But that may not be an issue for me if I can get the &amp;quot;write struct to NVS&amp;quot; issue I&amp;#39;ve had sitting in the background for a month or so now sorted.&amp;nbsp; Realistically, writing my data to flash each time I come out of System OFF will be a more robust solution that simply having retained RAM, as at some point the end user may need to replace the battery and they&amp;#39;d then lose all the historical data if I relied only on retained RAM.&lt;/p&gt;
&lt;p&gt;Sorting out writing a custom struct of data to NVS is my target this week.&amp;nbsp; I&amp;#39;ll hassle you on the other thread about that one if I get stuck&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/374263?ContentTypeID=1</link><pubDate>Mon, 27 Jun 2022 07:04:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f49f655-0ee8-4bdf-a467-2538827c130c</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Sorry about the late reply, but I have been out of office the last week and I&amp;#39;m only now getting to going through my backlog. To upload files or code snippets you can use the &amp;quot;Insert&amp;quot; dropdown menu in your reply.&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/pastedimage1656312070715v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Yes, NCS is our unofficial acronym of nRF Connect SDK. From the project configs it does indeed seem like it uses the LF clock. Glad to hear you were able to find a way around this.&lt;/p&gt;
&lt;p&gt;Did you try doing what Håkon is suggesting, disabling CONFIG_GPIO in MCUboot by creating a child image folder and creating an mcuboot.conf with &lt;strong&gt;CONFIG_GPIO=n&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/373562?ContentTypeID=1</link><pubDate>Wed, 22 Jun 2022 04:32:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d91f62f-cf5e-432f-8ef2-619e49a32509</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;I commented on another thread, that appeared related to my issues, and one of the other Nordic Engineers proposed some reasoning behind the ~ 400msec delay:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/89017/pin_cnf-sense-change-state/373231"&gt;RE: PIN_CNF Sense change state&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am actually using nRF Connect within VSC -&amp;nbsp;but I assume this is what Hakon is referring to when he mentions &amp;quot;NCS&amp;quot;?&lt;/p&gt;
&lt;p&gt;Seems this implements the LFCLK by default, regardless of whether I am using BLE at the time or not, which is what is causing the delay.&amp;nbsp; So, I was kind of on the right track.&lt;/p&gt;
&lt;p&gt;I have moved where I read the values of RESETREAS and LATCH into a SYS_INIT call in PRE_KERNEL_2 to overcome the 400msec delay issue, so I think I can park that part of the problem and say &amp;quot;its resolved&amp;quot;&lt;/p&gt;
&lt;p&gt;The issue I am still struggling with is the LATCH being reset if I get two GPIO triggers within this software start up period.&amp;nbsp; In my actual application, this is very likely to happen.&lt;/p&gt;
&lt;p&gt;What I&amp;#39;ve uncovered is that if I have&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_BOOTLOADER_MCUBOOT&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;in my proj.config file, then the problem of the LATCH register getting reset with the second GPIO trigger signal exists.&amp;nbsp; If I don&amp;#39;t have this in my prof.config file, then the LATCH signal remains intact and I can successfully grab the value of that in my SYS_INIT routine.&lt;/p&gt;
&lt;p&gt;I am writing&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_GPIO&lt;/span&gt;&lt;span&gt;-&amp;gt;PIN_CNF[&lt;/span&gt;&lt;span&gt;13&lt;/span&gt;&lt;span&gt;] &amp;amp;= &lt;/span&gt;&lt;span&gt;0x02&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;as the very first thing I do in my SYS_INIT function, so that the relevant GPIO is disconnected as an input and the SENSE is also disabled.&amp;nbsp; I&amp;#39;m doing this in an attempt to stop any subsequent reset triggers from the GPIO once the device has come out of System OFF.&amp;nbsp; But with the&amp;nbsp;CONFIG_BOOTLOADER_MCUBOOT=y statement present in my conf file, this appears to have no impact.&amp;nbsp; I will see a second reboot of the chip.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I&amp;#39;m even putting a 2sec wait at the end of my main.c, prior to putting the chip back into System OFF, so that I know its not actually going into System OFF when the second GPIO trigger comes along, but that&amp;#39;s not changing the behaviour I am seeing.&amp;nbsp; The issue seems to be that if I get a second GPIO trigger prior to my main.c code starting up, and with&amp;nbsp;CONFIG_BOOTLOADER_MCUBOOT=y, I will get LATCH reset to zero unexpectantly.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I am setting&amp;nbsp;CONFIG_BOOTLOADER_MCUBOOT=y because in my final application I need to have DFU functionality, and this was a requirement as indicated in the example code for DFU.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Any ideas how to get around this LATCH issue?&lt;br /&gt;&lt;br /&gt;Cheers,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Mike&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372914?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 06:22:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1f177f2-ea43-486c-a349-0edff1e00b12</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Not sure how to actually attach files on here.&amp;nbsp; But this is my proj.conf file:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PM=y
# Required to disable default behavior of deep sleep on timeout
CONFIG_PM_DEVICE=y
CONFIG_GPIO=y
# Optional select RAM retention (nRF52 only)
CONFIG_APP_RETENTION=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And this is the kconfig file:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

mainmenu &amp;quot;Nordic SYSTEM_OFF demo&amp;quot;

config APP_RETENTION
	bool &amp;quot;Enable state retention in system off&amp;quot;
	depends on SOC_COMPATIBLE_NRF52X
	help
	  On some Nordic chips this application supports retaining
	  memory while in system off.  Select this to enable the
	  feature.

source &amp;quot;Kconfig.zephyr&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve not changed either of these from the defaults that came with that example code.&lt;/p&gt;
&lt;p&gt;I am using VSC with the nRF Connect extension.&amp;nbsp; Not sure if that is causing some issues&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372909?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 06:05:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adbf6f55-beea-42e6-9577-cb2e986165f2</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Mike&lt;/p&gt;
&lt;p&gt;After looking through your main file and discussing this with a couple of colleagues, I still find this strange. It does not seem to be the delays in HW causing this, but rather something set in the application. My guess would be that some peripheral is taking time. Can you upload your configuration file (.conf) so we can make sure it doesn&amp;#39;t enable any peripheral taking extra time to start up. Because 400ms is too high for&amp;nbsp;&lt;em&gt;just&amp;nbsp;&lt;/em&gt;starting up the device.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372686?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2022 01:26:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecfe96bb-7e95-4275-83de-14d72e9468d1</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Putting the pin toggle in a SYS_INT call in either of the PRE_KERNEL stages (I&amp;#39;ve tried both PRE_KERNEL_1 and PRE_KERNAL_2) drops the start up delay down to &amp;lt; 400usec, which is more what I would have expected to see.&lt;/p&gt;
&lt;p&gt;I think if I can get my start-up delay to &amp;lt; 10msec, I can make things work for my application&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372680?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2022 00:07:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31a5c1f3-f700-4cdd-a304-e819bc671739</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;So, I&amp;#39;m using the system_off example in ...v1.9.1\zephyr\samples\boards\nrf\system_off and the only modifications I have made are:&lt;/p&gt;
&lt;p&gt;1. Configure P0.14 to be an output and set it low on start up&lt;/p&gt;
&lt;p&gt;2. Removed all the stuff about enabling/disabling the UART and putting it into various low(er) power modes&lt;/p&gt;
&lt;p&gt;3. Set P0.14 just prior to entering System Off&lt;/p&gt;
&lt;p&gt;4. Added a k_sleep() statement straight after the call to go into System Off, otherwise it doesn&amp;#39;t work (a known issue with the example code)&lt;/p&gt;
&lt;p&gt;The delay between my button0 signal going low, and my button1 signal going low, which is essentially measuring the time it takes to get to the first line in my main.c, is around 400msec, although it does vary a bit&lt;/p&gt;
&lt;p&gt;This is my main.c in full.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2019 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;init.h&amp;gt;
#include &amp;lt;pm/pm.h&amp;gt;
#include &amp;lt;pm/device.h&amp;gt;
#include &amp;quot;retained.h&amp;quot;
#include &amp;lt;hal/nrf_gpio.h&amp;gt;

#define CONSOLE_LABEL DT_LABEL(DT_CHOSEN(zephyr_console))

#define BUSY_WAIT_S 2U
#define SLEEP_S 2U

/* Prevent deep sleep (system off) from being entered on long timeouts
 * or `K_FOREVER` due to the default residency policy.
 *
 * This has to be done before anything tries to sleep, which means
 * before the threading system starts up between PRE_KERNEL_2 and
 * POST_KERNEL.  Do it at the start of PRE_KERNEL_2.
 */
static int disable_ds_1(const struct device *dev)
{
	ARG_UNUSED(dev);

	pm_constraint_set(PM_STATE_SOFT_OFF);
	return 0;
}

SYS_INIT(disable_ds_1, PRE_KERNEL_2, 0);

void main(void)
{
	/* Configure button 1 (P0.14) to be an output to allow start up delay measurement */
	nrf_gpio_cfg_output(DT_GPIO_PIN(DT_NODELABEL(button1), gpios));

	/* Toggle P0.14 output on startup.  P0.14 is linked to button1, which has a resistor pull-up, so need to clear it */
	nrf_gpio_pin_clear(DT_GPIO_PIN(DT_NODELABEL(button1), gpios));

	printk(&amp;quot;\n%s system off demo\n&amp;quot;, CONFIG_BOARD);

	if (IS_ENABLED(CONFIG_APP_RETENTION)) {
		bool retained_ok = retained_validate();

		/* Increment for this boot attempt and update. */
		retained.boots += 1;
		retained_update();

		printk(&amp;quot;Retained data: %s\n&amp;quot;, retained_ok ? &amp;quot;valid&amp;quot; : &amp;quot;INVALID&amp;quot;);
		printk(&amp;quot;Boot count: %u\n&amp;quot;, retained.boots);
		printk(&amp;quot;Off count: %u\n&amp;quot;, retained.off_count);
		printk(&amp;quot;Active Ticks: %&amp;quot; PRIu64 &amp;quot;\n&amp;quot;, retained.uptime_sum);
	} else {
		printk(&amp;quot;Retained data not supported\n&amp;quot;);
	}

	/* Configure to generate PORT event (wakeup) on button 1 press. */
	nrf_gpio_cfg_input(DT_GPIO_PIN(DT_NODELABEL(button0), gpios),
			   NRF_GPIO_PIN_PULLUP);
	nrf_gpio_cfg_sense_set(DT_GPIO_PIN(DT_NODELABEL(button0), gpios),
			       NRF_GPIO_PIN_SENSE_LOW);

	/* Reset P0.14 */
	nrf_gpio_pin_set(DT_GPIO_PIN(DT_NODELABEL(button1), gpios));

	printk(&amp;quot;Entering system off; press BUTTON1 to restart\n&amp;quot;);

	if (IS_ENABLED(CONFIG_APP_RETENTION)) {
		/* Update the retained state */
		retained.off_count += 1;
		retained_update();
	}

	/* Above we disabled entry to deep sleep based on duration of
	 * controlled delay.  Here we need to override that, then
	 * force entry to deep sleep on any delay.
	 */
	pm_power_state_force(0u, (struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
	k_sleep(K_SECONDS(SLEEP_S));
	printk(&amp;quot;ERROR: System off failed\n&amp;quot;);
	while (true) {
		/* spin to avoid fall-off behavior */
	}
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372587?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 13:16:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d792756a-728b-4473-a24d-a532afece343</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Okay, it shouldn&amp;#39;t take this long to wake up, can you show me your wake up procedure? This only makes sense if you initialize the BLE stack and thus starts up the oscillator. The wake up timings can be found in the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fpower.html"&gt;nRF52832 PS here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372501?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 08:18:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a932db12-fb5b-4431-9150-9eb446573b8d</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Thanks Simon.&lt;/p&gt;
&lt;p&gt;I ended up opening a new thread as I couldn&amp;rsquo;t respond to myself for some reason.&lt;/p&gt;
&lt;p&gt;The issue seems to be how long things take to exit System Off and start running my code. I&amp;rsquo;m seeing delays of 200-500msec!!!&lt;/p&gt;
&lt;p&gt;So, if I get two or more GPIO triggers in that time, it seems to reset&amp;nbsp;the value of LATCH and I can&amp;rsquo;t determine which GPIO caused the exit.&lt;/p&gt;
&lt;p&gt;The new thread is here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/88979/delay-between-exiting-system-off-and-starting-main-loop"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/88979/delay-between-exiting-system-off-and-starting-main-loop&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372484?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 07:41:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:223a775b-7ea0-430b-bd18-59532922ea92</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;After a second look at the wake up side of things:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;reset_reason = NRF_POWER-&amp;gt;RESETREAS;
gpio_trigger = NRF_GPIO-&amp;gt;LATCH;
printk(&amp;quot;reset_reason = %d\n&amp;quot;, reset_reason);
printk(&amp;quot;gpio_trigger = %d\n&amp;quot;, gpio_trigger);&lt;/pre&gt;&lt;br /&gt;Seems like this could cause some strange behavior. I think doing something like the following would be better:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;reset_reason = NRF_POWER-&amp;gt;RESETREAS;&lt;br /&gt;(void)NRF_TIMER0-&amp;gt;EVENTS_COMPARE[0];&lt;br /&gt;&lt;br /&gt;gpio_trigger = NRF_GPIO-&amp;gt;LATCH;&lt;br /&gt;...&lt;/p&gt;
&lt;p&gt;If you&amp;#39;d like, you can upload your project here and we can take a look on our side. Debugging is indeed tough when working on application going to system OFF as the CPU can&amp;#39;t go to system OFF while debugging.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372477?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2022 06:52:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14afe0bc-f53b-48af-8f3e-760f7ccb3bcf</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Apologies for the multiple posts.&amp;nbsp; I have been playing around with the original system_off example, to see if that displays the same behaviour (which it does).&amp;nbsp; So that led me to looking at some of the timing.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m monitoring two GPIO on by scope:&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp; The button signal that triggers the device out of System OFF&lt;/p&gt;
&lt;p&gt;2. A second GPIO that I set and then clear within my code, as the very first thing I do in my main loop upon start up&lt;/p&gt;
&lt;p&gt;What I&amp;#39;m seeing is a delay of anywhere from 200msec up to nearly 500msec between those two signals, which means there is upwards of 1/2sec a delay in some situations between the device being triggered out of System OFF, and my main loop commencing.&lt;/p&gt;
&lt;p&gt;If there is another GPIO trigger during that period, it does something to the value of the LATCH signals, such that they are all cleared.&amp;nbsp; So, when I then get to the point where I call:&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;NRF_GPIO&lt;/span&gt;&lt;span&gt;-&amp;gt;LATCH&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I get zero, rather than any indication of which GPIO caused the exit from System OFF.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;So, there are a few ways I can tackle this:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;1. Hardware - have a really, really long time constant on my GPIO inputs so I can&amp;#39;t get multiple triggers in &amp;lt; 500msec.&amp;nbsp; Seems very cludgy, and may mean I can&amp;#39;t actually get the performance I need&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;2. Work out why the code is taking so long to start up, and either reducing this time to &amp;lt; 50msec&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;3. Somehow shoe-horn the code where I grab the value of the LATCH signal much earlier in the start up sequence, so when my main loop eventually starts up, I&amp;#39;ve got the value stored there ready for use&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Any ideas what&amp;#39;s causing this delay, and how I can potentially reduce it?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Cheers,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Mike&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/372240?ContentTypeID=1</link><pubDate>Tue, 14 Jun 2022 01:08:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:242ce465-5cae-4f88-bd37-e9701e2bdbdb</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;I&amp;#39;ve been trying to emulate this behaviour in debug mode, but I&amp;#39;m not seeing it happen.&amp;nbsp; Essentially any subsequent button presses whilst my code is running are ignored (which is how I want it to work) and it only responds to a button press when its in System OFF.&amp;nbsp; So I can&amp;#39;t even work out why its behaving the way it is with debugging :-(&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/371990?ContentTypeID=1</link><pubDate>Sun, 12 Jun 2022 23:31:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdd8707e-b0d1-48e8-bb45-69d760bfe276</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Thanks for the link.&amp;nbsp; Seems pretty straight forward.&lt;/p&gt;
&lt;p&gt;I still think there is something else going on.&amp;nbsp; To test this, I put a simple 1 sec delay (using kmsleep() ) at the very start of my code, and then a similar 1 second delay just prior to my code going back into System OFF.&lt;/p&gt;
&lt;p&gt;This is the behaviour I see:&lt;/p&gt;
&lt;p&gt;Press one of the buttons to bring it out of System OFF mode - it will succesfully detect that a GPIO caused the exit (as indicated by RESETREAS), and will successfully detect which button was pressed (via LATCH).&amp;nbsp; It will then go back into System OFF mode&lt;/p&gt;
&lt;p&gt;Press one of the buttons to bring it out of System OFF mode, then within 0.5 sec (effectively whilst its still in its waiting mode), press the same button a second time - it will successfully detect that a GPIO caused the exit (as indicated by RESETEREAS) but it no longer is able to detect what button was pressed (via LATCH).&amp;nbsp; The result for LATCH = 0 in this case, which means I&amp;#39;ve got a scenario where my code has detected a GPIO has caused the exit from System OFF, but it can&amp;#39;t tell which button has caused it.&amp;nbsp; In this scenario, my code then just goes back into System OFF, and doesn&amp;#39;t update any of my counters.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using buttons in my testing, but ultimately the GPIO&amp;#39;s will be triggered via an external signal.&amp;nbsp; I will have three GPIO&amp;#39;s, corresponding to a &amp;quot;Small&amp;quot;, &amp;quot;Medium&amp;quot; or &amp;quot;Large&amp;quot; level on the external signal.&amp;nbsp; These signals are very transient (will only be present for a few tens of milliseconds) and with the behaviour I am seeing at the moment, if I get two external signals within a short period of time, rather than detecting the first and ignoring any subsequent ones (what I would prefer) its essentially not correctly detecting any of them.&amp;nbsp; And that&amp;#39;s what I&amp;#39;m trying to sort out.&lt;/p&gt;
&lt;p&gt;In my limited understanding, I think its something to do with the way the DETECT signal works.&amp;nbsp; And I&amp;#39;ve been trying to disable the GPIO from impacting the DETECT signal at the start of my code, via a call to:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrf_gpio_cfg_sense_input(pin, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_NOSENSE);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But this isn&amp;#39;t achieving what I want, so perhaps there is another way?&lt;/p&gt;
&lt;p&gt;So, what I want to be able to do the moment my code exits System OFF is:&lt;/p&gt;
&lt;p&gt;1. Check the value of RESETREAS&lt;/p&gt;
&lt;p&gt;2. Check the value of LATCH&lt;/p&gt;
&lt;p&gt;3. Disable any GPIO from triggering anything&lt;/p&gt;
&lt;p&gt;4. Process my counters based on the values of RESETREAS and LATCH&lt;/p&gt;
&lt;p&gt;5. Re-enable GPIO&amp;#39;s to allow exit from System OFF&lt;/p&gt;
&lt;p&gt;6. Enter System OFF&lt;/p&gt;
&lt;p&gt;Its step 3 that I seem to be unable to achieve&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/371785?ContentTypeID=1</link><pubDate>Fri, 10 Jun 2022 08:00:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51585851-e031-4e51-8bb6-35c99a12994f</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi MIke&lt;/p&gt;
&lt;p&gt;We already have a good discussion on how to implement debouncing to GPIOs in your application in&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/83636/debounce-in-callbacks/350294#350294"&gt; this thread &lt;/a&gt;that should be helpful. There is a &amp;quot;verified answer&amp;quot; with a code snippet shoing how/where you can add the debounce. As for the multiple button issue. Does just any button in your design wake the device from System OFF mode, and is that why you need the debounce on multiple buttons?&lt;/p&gt;
&lt;p&gt;As for your confusion between the GPIO functions in your previous answer I&amp;#39;m not sure how to explain it better than the descriptions of the functions themselves.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;nrf_gpio_cfg_input&lt;/strong&gt;: &amp;quot;Function for configuring the given GPIO pin number as input, hiding inner details. This function can be used to configure a pin as simple input.&amp;quot;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;strong&gt;gpio_pin_configure_dt: &amp;quot;&lt;/strong&gt;&lt;span&gt;Configure a single pin from a &lt;/span&gt;&lt;span&gt;@p&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;gpio_dt_spec&lt;/span&gt;&lt;span&gt; and some extra flags.&amp;nbsp;&lt;/span&gt;This is equivalent to: &lt;strong&gt;gpio_pin_configure(spec-&amp;gt;port, spec-&amp;gt;pin, spec-&amp;gt;dt_flags | extra_flags);&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards,&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Simon&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/371623?ContentTypeID=1</link><pubDate>Thu, 09 Jun 2022 11:07:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4d92a0d-4176-4077-be98-3ac797eeffa2</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi (again) Simon,&lt;/p&gt;
&lt;p&gt;OK, a little bit more paring down my code, and some late afternoon testing, and I think my issue is somehow related to this:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Trying to put the system to System OFF while DETECT is high will cause a wakeup from System OFF reset.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;What I do in my code when it first comes out of System OFF is the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;reset_reason = NRF_POWER-&amp;gt;RESETREAS;
gpio_trigger = NRF_GPIO-&amp;gt;LATCH;
printk(&amp;quot;reset_reason = %d\n&amp;quot;, reset_reason);
printk(&amp;quot;gpio_trigger = %d\n&amp;quot;, gpio_trigger);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I then check reset_reason and gpio_trigger to determine what, principally, caused the exit from System_OFF and, in the case of it being a GPIO state change, which of my GPIO was the cause of this.&amp;nbsp; The printk statements just let me check that what my code thinks has caused the exit, is actually the case.&lt;/p&gt;
&lt;p&gt;What I notice is that if I only push the button the once, I will get the correct values for reset_reason and gpio_trigger.&amp;nbsp; For example, if I push the button associated with P0.13, I will get:&lt;/p&gt;
&lt;p&gt;reset_reason = 0x1000&lt;/p&gt;
&lt;p&gt;gpio_trigger = 0x2000&lt;/p&gt;
&lt;p&gt;However, if I push the button several times in quick succession, I will not get the correct value for gpio_trigger; this will almost always come back as zero, even though the reset_reason value is correct.&lt;/p&gt;
&lt;p&gt;I put a&amp;nbsp;&lt;span&gt;k_sleep(&lt;/span&gt;&lt;span&gt;K_SECONDS&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;));&amp;nbsp;&lt;/span&gt;statement just prior to going back into System_OFF, to delay things for a second and thus try and prevent the multiple button press issue.&amp;nbsp; This doesn&amp;#39;t work reliably - if I press one button and then quickly a second one, I can get the issue described above where the gpio_trigger value comes out as zero.&lt;/p&gt;
&lt;p&gt;Does it look like I&amp;#39;m on the right track in terms of thinking the DETECT signal is what is causing the second reset (even though my code is in the middle of operating at the time of the second button press)?&amp;nbsp; And if so, is a software GPIO debounce at the very start of my code, where I just loop around until all the GPIOs have returned to their non-trigger state, the best approach to resolving it?&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/371539?ContentTypeID=1</link><pubDate>Thu, 09 Jun 2022 06:06:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a43bd86-558f-4a9f-b1ba-e6ad732a377d</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Thanks Simon.&lt;/p&gt;
&lt;p&gt;I think I may have solved my problem.&amp;nbsp; Lets just say I had a convoluted mess of various gpio configs and interrupt configs, and when I stripped everything back to the basics to test what was causing my issue, it looks like the multiple reset issue has gone away.&amp;nbsp; But I&amp;#39;ll need to do a bit more investigations to be sure of that, using something that can operate my GPIO a bit quicker than I can!&lt;br /&gt;&lt;br /&gt;I think my confusion (and it still exists to an extent) is trying to understand the difference between using:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;nrf_gpio_cfg_input(pin, flags) &amp;amp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;nrf_gpio_cfg_sense_input(pin, flags)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;compared to using:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;gpio_pin_configure_dt(spec, flags)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I think its something to do with the difference between GPIO and GPIOTE, in that I need to use the nrf_gpio API&amp;#39;s to set up my GPIO to trigger out of System-Off mode, but then need to use the gpio_pin_configure API&amp;#39;s to set up those GPIO if I want to read in their status whilst my code is running.&amp;nbsp; But don&amp;#39;t quote me on that!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Any clarification would be greatly appreciate :-)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Cheers,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Mike&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple GPIO interrupts from SYSTEM_SOFT_OFF</title><link>https://devzone.nordicsemi.com/thread/369890?ContentTypeID=1</link><pubDate>Mon, 30 May 2022 07:49:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85405f54-18cd-4cfe-8e2c-47ae9f739cce</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Mike&lt;/p&gt;
&lt;p&gt;Yes, verifying an answer will mark your ticket as &amp;quot;resolved&amp;quot; and lock it. For the nRF52832 you also have the option to use the &lt;a href="https://infocenter.nordicsemi.com/topic/struct_sdk/struct/sdk_nrf5_latest.html"&gt;nRF5 SDK&lt;/a&gt;, but this SDK is only in maintenance mode, so for new designs we recommend using the nRF Connect SDK instead. See&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/nrf-connect-sdk-and-nrf5-sdk-statement"&gt; the nRF Connect SDK and nRF5 SDK statement &lt;/a&gt;for more details.&lt;/p&gt;
&lt;p&gt;I still think that adding the debounce will fix the issue with multiple button presses after the initial one, as that will not cause any interrupts after pressing the button once until the debounce duration is done. Then you&amp;#39;ll have to set the button input as disconnected for example to make the button not do anything until you go to sleep again. I don&amp;#39;t think using another low power mode will help much, as the wake up GPIO will function similarly no matter what sleep mode the device is in.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Debounce in the nRF Connect SDK uses the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/gpio.html?highlight=debounce#c.GPIO_INT_DEBOUNCE"&gt;GPIO_DEBOUNCE&lt;/a&gt;&amp;nbsp;flag to add a debounce to GPIOs I believe, and it can be seen &amp;quot;in action&amp;quot; in the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/boards/nrf/mesh/onoff-app/README.html"&gt;BLE Mesh OnOff Model sample here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>