<?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>CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88131/caf-latch-register-for-all-button-gpios-are-set-when-wakeup-from-deep-sleep-by-single-button-press-making-it-impossible-to-know-which-button-that-did-the-wakeup</link><description>I used the Common Application Framework preview sample, with the following additions at end of prj.conf: 
 
 NCS 1.9.1 was used 
 The nrf52840dk then enters deep sleep after 10 seconds. 
 When I then perform a button wakeup, by clicking one of the DK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Jun 2022 09:20:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88131/caf-latch-register-for-all-button-gpios-are-set-when-wakeup-from-deep-sleep-by-single-button-press-making-it-impossible-to-know-which-button-that-did-the-wakeup" /><item><title>RE: CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup</title><link>https://devzone.nordicsemi.com/thread/370379?ContentTypeID=1</link><pubDate>Wed, 01 Jun 2022 09:20:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03e83ce1-4ac7-4ac8-8733-789b1ccf112b</guid><dc:creator>tellg</dc:creator><description>&lt;p&gt;Yes, and my attached project solves this for my purpose, as I can check the cause of wakeup. My application (not shown in the project) will go back to sleep if woken up by the wrong button. This works at least when not debugging (by checking and clearing the GPIO latch register). When debugging, any button wakeup will set the corresponding GPIO latch bit for ALL of the CAF buttons, while if I only flash instead of starting debugging, I can see via the GPIO latch register which button caused the wakeup.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can see this by looking at the NRF terminal output:&lt;/p&gt;
&lt;p&gt;1) Here I woke up the board by DK Button 1, not using debugger:&lt;/p&gt;
&lt;p&gt;*** Booting Zephyr OS build v2.7.99-ncs1-1 ***&lt;br /&gt;[00:00:00.375,671] &amp;lt;inf&amp;gt; main: NRF_P0-&amp;gt;LATCH, at wakeup =&lt;span style="color:#339966;"&gt; &lt;strong&gt;0x00000800&lt;/strong&gt;&lt;/span&gt;, after clear = 0x00000000&lt;/p&gt;
&lt;p&gt;As you will see, the latch value marked in&amp;nbsp;GREEN indicates the bit set for DK Button 1&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2) Here I woke up the board by DK Button 4, not using debugger:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;*** Booting Zephyr OS build v2.7.99-ncs1-1 ***&lt;br /&gt;[00:00:00.380,859] &amp;lt;inf&amp;gt; main: NRF_P0-&amp;gt;LATCH, at wakeup = &lt;span style="color:#339966;"&gt;&lt;strong&gt;0x02000000&lt;/strong&gt;&lt;/span&gt;, after clear = 0x00000000&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As you will see, the latch value marked in GREEN indicates the bit set for DK Button 4&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;3) Here I woke up the board by DK Button 4, &lt;strong&gt;&lt;span style="color:#ff0000;"&gt;and using debugger&lt;/span&gt;:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;*** Booting Zephyr OS build v2.7.99-ncs1-1 ***&lt;br /&gt;[00:00:00.379,150] &amp;lt;inf&amp;gt; main: NRF_P0-&amp;gt;LATCH, at wakeup = &lt;strong&gt;&lt;span style="color:#ff0000;"&gt;0x03001800&lt;/span&gt;&lt;/strong&gt;, after clear = 0x00000000&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As you will see, the latch value marked in RED indicates the bits set for all 4 DK buttons.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But as I mentioned earlier, this is only a problem when running a debug session.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You may close this ticket.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup</title><link>https://devzone.nordicsemi.com/thread/370366?ContentTypeID=1</link><pubDate>Wed, 01 Jun 2022 08:49:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ade7447-0ddb-49a7-b2ab-6a7a36b23efb</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Unfortunately the CAF button module does not allow to mention which key should be used for wake up etc. So if you want have a wakeup using only one of the DK buttons, you could try to go back to sleep if all other buttons are pressed.&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup</title><link>https://devzone.nordicsemi.com/thread/369272?ContentTypeID=1</link><pubDate>Tue, 24 May 2022 11:48:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6779f884-b7e9-4389-91f6-f0974107712c</guid><dc:creator>tellg</dc:creator><description>&lt;p&gt;Yes the screenshot was for before the one I shared.&lt;/p&gt;
&lt;p&gt;The problem is still there if I start a debug session instead of just flashing the nRF52840dk board&lt;/p&gt;
&lt;p&gt;I used the built-in debugger on the board, not an external J-Link&lt;/p&gt;
&lt;p&gt;Board label is: PCA10056, 2.0.2, 2021.43, 683783911&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0576.caf.zip"&gt;devzone.nordicsemi.com/.../0576.caf.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup</title><link>https://devzone.nordicsemi.com/thread/369262?ContentTypeID=1</link><pubDate>Tue, 24 May 2022 11:39:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ea0c53f-fefc-42e2-a896-78c6c111e3bb</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am not able to reproduce the problem at my end so far. I have a few questions though.&lt;/p&gt;
&lt;p&gt;In the screenshot that you shared, it looks like you are trying the default main file for caf and not the one that you have shared here in the ticket.&lt;/p&gt;
&lt;p&gt;Also, when you say that you are not able to latch separately when using a debugger, do you mean that when you start the debug session, you get this error? or only when you connect an external debugger this problem arises?&lt;/p&gt;
&lt;p&gt;Could you share a zip file of your entire project folder so that I can try to reproduce it here?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup</title><link>https://devzone.nordicsemi.com/thread/369079?ContentTypeID=1</link><pubDate>Mon, 23 May 2022 14:19:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70809887-e2a6-4d7e-8ed8-06173ebaa7ce</guid><dc:creator>tellg</dc:creator><description>&lt;p&gt;7.60c&lt;/p&gt;
&lt;p&gt;It also seems like after running with debugger, I have to flash again (using flash button) to get it to work again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup</title><link>https://devzone.nordicsemi.com/thread/369075?ContentTypeID=1</link><pubDate>Mon, 23 May 2022 14:10:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1875e363-9e16-4cb1-be54-30919eacfb81</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What is your J-Link version?&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CAF: Latch register for all button GPIOS are set when wakeup from deep sleep by single button press, making it impossible to know which button that did the wakeup</title><link>https://devzone.nordicsemi.com/thread/368835?ContentTypeID=1</link><pubDate>Fri, 20 May 2022 12:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a2252fe-c58a-4921-92ce-beaa26bed356</guid><dc:creator>tellg</dc:creator><description>&lt;p&gt;Seems to be a problem only when debugger is active.&lt;/p&gt;
&lt;p&gt;But to get the real button wakeup source, the latch can be read and cleared in&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;PRE_KERNEL_1 hook&amp;nbsp;&lt;/span&gt;before main() as shown in attached modified main.c&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/773083.main.c"&gt;devzone.nordicsemi.com/.../773083.main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please note that the original issue is still present if running with debugger.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>