<?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>GPIO Interrupt with BLE peripheral code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37328/gpio-interrupt-with-ble-peripheral-code</link><description>Hi, I am currently testing some BLE sample code (the proximity code and hrs code) with the nRF52840 PDK and I am trying to just simply interface the GPIO interrupt example (pin_change_int) with either of these. I found this post ( https://devzone.nordicsemi</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 Aug 2018 14:14:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37328/gpio-interrupt-with-ble-peripheral-code" /><item><title>RE: GPIO Interrupt with BLE peripheral code</title><link>https://devzone.nordicsemi.com/thread/143994?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 14:14:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:131597ea-88f8-4464-9e85-2a0b8bbe57a1</guid><dc:creator>sallott</dc:creator><description>&lt;p&gt;Thank you for thoroughly explaining this.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO Interrupt with BLE peripheral code</title><link>https://devzone.nordicsemi.com/thread/143935?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 12:04:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed6aeb7d-de2b-4f7f-956b-499dd4c13c88</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;&lt;span style="font-weight:400;"&gt;When trying to integrate the pin_change_int example with the ble_app_proximity example I got the same error as you (running &lt;/span&gt;&lt;em&gt;&lt;span style="font-weight:400;"&gt;both &lt;/span&gt;gpio_init() &lt;/em&gt;&lt;span style="font-weight:400;"&gt;and &lt;/span&gt;&lt;em&gt;&lt;span style="font-weight:400;"&gt;buttons_leds_init(&amp;amp;erase_bonds)&lt;/span&gt;&lt;/em&gt;&lt;span style="font-weight:400;"&gt;). However, in my case using sdk 15 and the ble_app_proximity example the function &lt;em&gt;nrf_drv_gpiote_is_init() &lt;/em&gt;is already implemented inside &lt;em&gt;buttons_leds_init(..)&lt;/em&gt; --&amp;gt; &lt;em&gt;bsp_init(..)&lt;/em&gt; --&amp;gt; &lt;em&gt;app_button_init(..).&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;But the error still remains, and after debugging, it is due to calling &lt;em&gt;nrf_drv_gpiote_in_init(..)&lt;/em&gt; two times:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;span style="font-weight:400;"&gt;In the ble_app_proximity example:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;It is called&amp;nbsp;inside&lt;em&gt; buttons_leds_init(..)&lt;/em&gt; &amp;rarr; &lt;em&gt;bsp_init(..)&lt;/em&gt; &amp;rarr; &lt;em&gt;app_button_init(..)&lt;/em&gt; &amp;rarr; &lt;/span&gt;&lt;span style="font-weight:400;"&gt;nrf_drv_gpiote_in_init(..)&lt;/span&gt;&lt;span style="text-decoration:underline;"&gt;&lt;span style="font-weight:400;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;Button 1 to 4 is initialized using&amp;nbsp;low accuracy and the sense feature&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;&lt;span style="font-weight:400;"&gt;In the pin_change_init example:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;It is called inside &lt;em&gt;gpio_init()&lt;/em&gt; &amp;rarr; &lt;em&gt;nrf_drv_gpiote_in_init(..)&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-weight:400;"&gt;Here button 1 is initialized using&amp;nbsp;high accuracy and IN_EVENT is enabled&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;The problem is that button 1 is used by both of the examples.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;I solved it by defining PIN_IN and PIN_OUT to respectively button 3 and led 3, then the pin_change_int functionality be changed to control LED 4 with button 4. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Then I changed the definition of BUTTONS_NUMBER from 4 to 3, inside pca10056.h (It&amp;nbsp;might be smart to make a&amp;nbsp;copy of the edited file, in case you will use this header file in other projects), then the buttons_leds_init() function will only initialize button 1 to 3. The ble app_proximity will still work as expected, since it only uses button 1 and&amp;nbsp;2 (according to function &lt;em&gt;bsp_event_handler(..)&lt;/em&gt;).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Remember to call &lt;em&gt;gpio_init()&lt;/em&gt; first, if not you have to swap these lines (inside gpio_init):&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;with these lines:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;if (!nrf_drv_gpiote_is_init())
    {
        err_code = nrf_drv_gpiote_init();
        VERIFY_SUCCESS(err_code);
    }&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;Best regards Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>