<?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>Bug in app_gpiote.c and an improvement for ISR in nrfx_gpiote.c</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94165/bug-in-app_gpiote-c-and-an-improvement-for-isr-in-nrfx_gpiote-c</link><description>Background: My colleague encountered a problem on using GPIOTE for detecting multiple interrupts with the API from app_gpiote.c in SDK17. When there are more than 2 interrupts triggered at the same time, it is possible that some of them would be lost</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Nov 2022 11:54:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94165/bug-in-app_gpiote-c-and-an-improvement-for-isr-in-nrfx_gpiote-c" /><item><title>RE: Bug in app_gpiote.c and an improvement for ISR in nrfx_gpiote.c</title><link>https://devzone.nordicsemi.com/thread/397847?ContentTypeID=1</link><pubDate>Mon, 28 Nov 2022 11:54:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fda153c-3ca6-45f2-b85f-8871fb799ca0</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I will just put it in a waiting state, so it will be opened whenever someone write to it any time in the future &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in app_gpiote.c and an improvement for ISR in nrfx_gpiote.c</title><link>https://devzone.nordicsemi.com/thread/397376?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2022 11:01:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6ecf373-9c3f-4a49-bf0a-911b164b5b30</guid><dc:creator>anikchen</dc:creator><description>&lt;p&gt;Thanks Edvin, I really appreciate your recognition, and would keep this thread open for one week to someone who maybe want to comment on it.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Anik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in app_gpiote.c and an improvement for ISR in nrfx_gpiote.c</title><link>https://devzone.nordicsemi.com/thread/397312?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2022 07:47:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a33f0a4e-8646-413f-b4bb-20f5700e3004</guid><dc:creator>Edvin</dc:creator><description>[quote user="anikchen"]&lt;p&gt;You are also right that &amp;quot;That is a limitation of the module.&amp;quot;. However, it should be as reliable as possible to minimize the risk. Indeed the driver level in nrfx_gpiote.c uses some hardware features to do that, such as LATCH in PORT EVENT, with which the interrupt could be held until it&amp;#39;s processed. But it&amp;#39;s a pity that the app level in app_gpiote.c doesn&amp;#39;t utilize this feature.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I totally agree!&amp;nbsp;&lt;/p&gt;
[quote user="anikchen"]And this really happened in the situation while 2 interrupts are triggered at the same time.[/quote]
&lt;p&gt;Yes. It is a good point.&amp;nbsp;&lt;/p&gt;
[quote user="anikchen"]E&amp;gt; Thanks a lot for your support. I noticed and understood. Event the team has no schedule, it&amp;#39;s also a good thing if this thread could help someone here who maybe encounter the same problem.[/quote]
&lt;p&gt;That is also a very good point! Thank you for sharing! This is all valuable feedback!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in app_gpiote.c and an improvement for ISR in nrfx_gpiote.c</title><link>https://devzone.nordicsemi.com/thread/397296?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2022 02:59:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12e5a5e3-1bdf-4a2c-8329-626355b3077c</guid><dc:creator>anikchen</dc:creator><description>&lt;p&gt;Thanks for your comments!&lt;/p&gt;
&lt;p&gt;A&amp;gt; You are right. I am using low accuracy as I call the API &amp;lt;app_gpiote_user_register()&amp;gt; in which the hi_accuracy is set to&amp;nbsp;default false (PORT EVENT):&amp;nbsp;const nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);&lt;/p&gt;
&lt;p&gt;And even I manually set it to true (IN EVENT), it also works with the same problem because both IN EVENT and PORT EVENT use the shared callback &amp;lt;gpiote_handler()&amp;gt;&amp;nbsp;where the bug locates in app_gpiote.c. Of course, I already tested and checked this.&lt;/p&gt;
&lt;p&gt;B&amp;gt; You are also right that &amp;quot;That is a limitation of the module.&amp;quot;. However, it should be as reliable as possible to minimize the risk. Indeed the driver level in nrfx_gpiote.c uses some hardware features to do that, such as LATCH in PORT EVENT, with which the interrupt could be held until it&amp;#39;s processed. But it&amp;#39;s a pity that the app level in app_gpiote.c doesn&amp;#39;t utilize this feature.&lt;/p&gt;
&lt;p&gt;C&amp;gt; The logic of&amp;nbsp; the app level is: it receives events through &amp;lt;gpiote_handler()&amp;gt; from the driver level. Then it makes the decision on whether the event is rising triggering or falling triggering just according to the last pin state. If the last pin state is High, it would deliver a HiToLo event to user application callback registered by &amp;lt;&lt;span&gt;app_gpiote_user_register()&amp;gt;&lt;/span&gt;, and vice versa. As we can see, the last pin state decided everything. If something unexpectedly changed it&amp;#39;s value, the user application would get an unexpected event accordingly. And this really happened in the situation while 2 interrupts are triggered at the same time.&lt;/p&gt;
&lt;p&gt;D&amp;gt; It&amp;#39;s a good option to use the API in nrfx_gpiote.c skipping app_gpiote.c just like what &amp;quot;&lt;span&gt;the implementation that is used in SDK\examples\peripheral\pin_change_int&lt;/span&gt;&amp;quot; do. But sometimes, for most developers, the official library is the first choice as it&amp;#39;s much convenient to get started and able to boost the development.&lt;/p&gt;
&lt;p&gt;E&amp;gt; Thanks a lot for your support. I noticed and understood. Event the team has no schedule, it&amp;#39;s also a good thing if this thread could help someone here who maybe encounter the same problem.&lt;/p&gt;
&lt;p&gt;Thanks Edvin and Best regards,&lt;/p&gt;
&lt;p&gt;Anik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in app_gpiote.c and an improvement for ISR in nrfx_gpiote.c</title><link>https://devzone.nordicsemi.com/thread/397174?ContentTypeID=1</link><pubDate>Wed, 23 Nov 2022 13:25:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea2a2d8e-55fa-4c28-9121-5d04ae5d3702</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am aware that if you are using low accuracy, which means high_accuracy = 0 in:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/** @brief Input pin configuration. */
typedef struct
{
    nrf_gpiote_polarity_t sense;               /**&amp;lt; Transition that triggers the interrupt. */
    nrf_gpio_pin_pull_t   pull;                /**&amp;lt; Pulling mode. */
    bool                  is_watcher      : 1; /**&amp;lt; True when the input pin is tracking an output pin. */
    bool                  hi_accuracy     : 1; /**&amp;lt; True when high accuracy (IN_EVENT) is used. */
    bool                  skip_gpio_setup : 1; /**&amp;lt; Do not change GPIO configuration */
} nrfx_gpiote_in_config_t;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You will get an interrupt on every pin change, but since this is a low accuracy / low power approach, the event itself will not hold the state of the pin that triggered the task, but this will be read out by the state of the pin that triggered the task, and add it to the user event. That is a limitation of the module.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That being said, I couldn&amp;#39;t say that I recognized the gpiote_handler, and I see that out of the box, this module is not used in any of the examples. Not saying it doesn&amp;#39;t work, but I don&amp;#39;t know the inns and outs of it. If I need &amp;quot;raw&amp;quot; gpio handlers, I usually use the implementation that is used in SDK\examples\peripheral\pin_change_int, where you can choose between hi_accuracy enabled or disabled.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will forward your input to the developer team, but seeing as the nRF5 SDK is in maintenance mode, I am not sure when/if they will look into it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>