<?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>Hot to detect the GPIO status with Timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55006/hot-to-detect-the-gpio-status-with-timer</link><description>I would like to make a timer to check the GPIO status. 
 The current code is like below: 
 
 I already checked that timer function is worked by implant the specific event into the charge_event_handler as below: 
 charge_event_handler(TYPE_C,GPIOTE_CONFIG_POLARITY_LoToHi</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 29 Nov 2019 10:05:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55006/hot-to-detect-the-gpio-status-with-timer" /><item><title>RE: Hot to detect the GPIO status with Timer</title><link>https://devzone.nordicsemi.com/thread/222746?ContentTypeID=1</link><pubDate>Fri, 29 Nov 2019 10:05:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:510704a9-61a3-41f1-b9a7-7667e448bad5</guid><dc:creator>Ali Rumane</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Good to know it works!&lt;/p&gt;
&lt;p&gt;If you have a button or wakeup interrupt from button/IC or similar case you can use GPIOTE which is a peripheral that generates events on pin state change or as configured.&lt;/p&gt;
&lt;p&gt;You can look at posts and infocenter here to know more&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fgpiote.html"&gt;Link &lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/25114/gpio-vs-gpiote-usage"&gt;Link &lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/2841/how-gpio-related-to-gpiote"&gt;Link&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Peripherals can interact with tasks and events independent of CPU with Programmable peripheral interconnect (PPI). You can learn more about it &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fppi.html"&gt;here &lt;/a&gt;and in this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/15491/ppi-nrf52832"&gt;post&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Do let us know if it helps or need some understanding.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;Regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;"&gt;(Note: I have sighted nRF52832 as an example. You can refer Product specification of your case.)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hot to detect the GPIO status with Timer</title><link>https://devzone.nordicsemi.com/thread/222706?ContentTypeID=1</link><pubDate>Fri, 29 Nov 2019 07:46:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0659aed3-65b6-40f0-bf09-fe1d3e96a777</guid><dc:creator>CY</dc:creator><description>&lt;p&gt;Hi Ali,&lt;/p&gt;
&lt;p&gt;I just tried your suggestion, and it work properly.&lt;/p&gt;
&lt;p&gt;I am curious about what is the different between using GPIO and GPIOTE? Will it make power consumption different?&lt;/p&gt;
&lt;p&gt;Honestly, I do not familiar with PPI why it could be used with GPIOTE or why it need? Does it have any benefit?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hot to detect the GPIO status with Timer</title><link>https://devzone.nordicsemi.com/thread/222698?ContentTypeID=1</link><pubDate>Fri, 29 Nov 2019 06:38:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:263cfd94-c440-4bd2-92e7-17fe248b3749</guid><dc:creator>Ali Rumane</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="74727" url="~/f/nordic-q-a/55006/hot-to-detect-the-gpio-status-with-timer"][/quote]
&lt;p&gt;&lt;span&gt;But not sure how to make it switch from different event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Not sure what you want to achieve or different event as in?&lt;/p&gt;
&lt;p&gt;Are you disabling gpiote from some other function? It is being reinitialized every time a timeout occurs.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void charge_check_status(void)
{
    if (!nrf_gpio_pin_read(TYPE_C))
	{
		nrf_gpio_pin_set(LED_2);
	}
	else
	{
	    nrf_gpio_pin_clear(LED_2);
	}
}


static void application_timers_start(void)
{
    ret_code_t err_code;

	err_code = app_timer_start(m_charge_timer_id, CHARGE_MEAS_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);
}

static void charge_meas_timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
	charge_check_status();
}

static void timers_init(void)
{
    // Initialize timer module.
    ret_code_t err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);

    err_code = app_timer_create(&amp;amp;m_charge_timer_id,
                                APP_TIMER_MODE_REPEATED,
                                charge_meas_timeout_handler);
}


// Initialise the GPIO
void gpio_init(void)
{
    // LED_2 can be initialised here

    // Initialise TYPE_C as input
    nrf_gpio_cfg_input(TYPE_C , NRF_GPIO_PIN_PULLUP);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have&amp;nbsp;a simple code that reads pin status after a timeout occurs.&lt;/p&gt;
&lt;p&gt;You can use gpiote with ppi in case you want it for your application. Do let me know if it works or what do you want to implement.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>