<?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>nrf9160 GPIOTE with Interrupt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79218/nrf9160-gpiote-with-interrupt</link><description>Hi 
 i am using nrf9160 based custom board with zephyr, and trying to build GPIOTE with interrupt for a button, and led finally connect with PPI 
 
 i have been trying for Blinky using GPIOTE like this: 
 
 prj.conf file: 
 
 after uploading, the code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 06 Sep 2021 07:48:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79218/nrf9160-gpiote-with-interrupt" /><item><title>RE: nrf9160 GPIOTE with Interrupt</title><link>https://devzone.nordicsemi.com/thread/328108?ContentTypeID=1</link><pubDate>Mon, 06 Sep 2021 07:48:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63adfb6b-8fe8-4494-9480-cd149a25c17a</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Can you add some debugging by:&lt;/p&gt;
&lt;div&gt;&lt;span&gt;CONFIG_ASSERT&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_ASSERT_VERBOSE&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_ASSERT_NO_COND_INFO&lt;/span&gt;&lt;span&gt;=n&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_ASSERT_NO_MSG_INFO&lt;/span&gt;&lt;span&gt;=n&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_RESET_ON_FATAL_ERROR&lt;/span&gt;&lt;span&gt;=n&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf9160 GPIOTE with Interrupt</title><link>https://devzone.nordicsemi.com/thread/327902?ContentTypeID=1</link><pubDate>Fri, 03 Sep 2021 07:45:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e70d478d-13a3-4977-a178-b7aa7e017915</guid><dc:creator>Rajender</dc:creator><description>&lt;p&gt;Hi kenneth,&lt;/p&gt;
&lt;p&gt;Thank you very much,&lt;/p&gt;
&lt;p&gt;The only change i done to your code is &lt;strong&gt;IRQ_CONNECT(GPIOTE1_IRQn, 7, nrfx_isr, nrfx_gpiote_irq_handler, 0); &lt;/strong&gt;(of course i changed &lt;span&gt;CONFIG_GPIO&lt;/span&gt;&lt;span&gt;=n&lt;/span&gt; also)&lt;/p&gt;
&lt;p&gt;but i didnt understand one thing, when i use GPIOTE0_IRQn in above function the board is restarting, im using port 0 for the gpio but still why its happening like that?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr.h&amp;gt;


#include &amp;lt;nrfx_gpiote.h&amp;gt;

#define LED_1 DT_GPIO_PIN(DT_ALIAS(led1), gpios)
#define LED_2 DT_GPIO_PIN(DT_ALIAS(led2), gpios)
#define BTN   DT_GPIO_PIN(DT_ALIAS(factoryrestore), gpios)


void button_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
nrf_gpio_pin_toggle(LED_1);
  
}

void gpio_inits(void)
{

  nrfx_err_t err;

  IRQ_CONNECT(GPIOTE1_IRQn, 7, nrfx_isr, nrfx_gpiote_irq_handler, 0);

  if (!nrfx_gpiote_is_init()) {
    err = nrfx_gpiote_init(0);
  }
	nrf_gpio_cfg_output(LED_1);
        nrf_gpio_cfg_output(LED_2);
   //------------------------------------------------------------------------------------------------
	nrfx_gpiote_in_config_t const in_config = {
		.sense = NRF_GPIOTE_POLARITY_HITOLO,
		.pull = NRF_GPIO_PIN_PULLUP,
		.is_watcher = false,
		.hi_accuracy = true,
		.skip_gpio_setup = false,
	};

	err = nrfx_gpiote_in_init(BTN, &amp;amp;in_config, button_handler);
	if (err != NRFX_SUCCESS) {
		printk(&amp;quot;nrfx_gpiote_in_init error: %08x&amp;quot;, err);
		return;
	}

	nrfx_gpiote_in_event_enable(BTN, true);

}

void main(void)
{
gpio_inits();
nrf_gpio_pin_set(LED_1);
while (1)
{
  nrf_gpio_pin_toggle(LED_2);
  k_sleep(K_MSEC(1000)); 
}


}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;
&lt;p&gt;Rajender&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf9160 GPIOTE with Interrupt</title><link>https://devzone.nordicsemi.com/thread/327759?ContentTypeID=1</link><pubDate>Thu, 02 Sep 2021 11:04:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81688e81-aedd-4b9e-a32f-e3812c9f3e52</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I believe you will need to set:&amp;nbsp;&lt;span&gt;CONFIG_GPIO&lt;/span&gt;&lt;span&gt;=n, e&lt;/span&gt;&lt;span&gt;lse zephyr will control the GPIOTE peripheral (thereby no interrupt).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This example I made some time ago should show an example how it can be done:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/66488/using-spi-with-ppi-in-zephyr/272139#272139"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/66488/using-spi-with-ppi-in-zephyr/272139#272139&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>