<?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>What function should be used to associate an interrupt with an event?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67266/what-function-should-be-used-to-associate-an-interrupt-with-an-event</link><description>I wanted to know the function or functions and the steps to associate an interrupt with an event. 
 I will be getting a single Pulse(Low To High) which will be my interrupt signal. 
 I wanted to read this and generate an event to sleep. 
 Can someone</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 20 Oct 2020 10:41:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67266/what-function-should-be-used-to-associate-an-interrupt-with-an-event" /><item><title>RE: What function should be used to associate an interrupt with an event?</title><link>https://devzone.nordicsemi.com/thread/275855?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 10:41:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f258077-9f54-4a99-bdeb-8b6471d6d239</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First off,&amp;nbsp;do yourself a favour and use the latest SDK (v17.0.2) as this contains improvements, bug fixes and supports the latest devices. This could save you time and frustration down the road.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Summarized this example idles in the main loop until it gets an interrupt from the GPIO (button) being toggled, in which case it executes the code inside the event handler.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="RJD"]Also how does this line work-&amp;nbsp;nrf_drv_gpiote_in_init(PIN_IN, &amp;amp;in_config, in_pin_handler);[/quote]
&lt;p&gt;&amp;nbsp;This initates GPIOTE on &lt;em&gt;PIN_IN&lt;/em&gt; using the settings in &lt;em&gt;in_config&lt;/em&gt;, and triggering an interrupt on the in event which will run the code in &lt;em&gt;in_pin_handler&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="RJD"]As in_pin_handler is a function and also not of type&amp;nbsp;&amp;nbsp;nrfx_gpiote_evt_handler_t&amp;nbsp; &amp;nbsp;but void [/quote]
&lt;p&gt;&amp;nbsp;Not sure why this is done, you can change this if you want.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="RJD"]And also why does&amp;nbsp;&lt;span&gt;nrf_drv_gpiote_in_init does throw an error when in_pin_handler is called on being of a void type and not&amp;nbsp;nrfx_gpiote_evt_handler_t&lt;/span&gt;[/quote]
&lt;p&gt;Not sure what you mean, this builds fine on my side.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="RJD"]How are the parameters being passed to&amp;nbsp;in_pin_handler in&amp;nbsp;nrf_drv_gpiote_in_init[/quote]
&lt;p&gt;Not sure I understand what you mean. This is handled by the driver though, you should look through the code and documentation.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="RJD"]Q3- How and where are the &amp;quot;action&amp;quot; parameter being generated&amp;nbsp; and passed[/quote]
&lt;p&gt;Do you mean what is triggering the event?&amp;nbsp; This is determined through the settings in the&amp;nbsp;&lt;em&gt;in_config&lt;/em&gt; supplied when calling &lt;em&gt;nrf_drv_gpiote_in_init&lt;/em&gt;: &lt;em&gt;in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true)&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="RJD"]Q4- Also how to associate the action(function name(s) too) with an event to put the device to sleep or any other event I want to use it for?[/quote]
&lt;p&gt;Not sure I understand, but it is hard to give a generic solution. It depends on what you want to do, but in general when the chip has executed the event handler it will return to the main while loop in this case. To go to sleep you might need to add a &lt;em&gt;__WFE();&lt;/em&gt; in the main loop.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What function should be used to associate an interrupt with an event?</title><link>https://devzone.nordicsemi.com/thread/275735?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 01:19:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e8c5194-04e6-40c2-b716-92cccda6fbb5</guid><dc:creator>RJD</dc:creator><description>&lt;p&gt;Hello ANdreas, there is another thing, I want to combine this code&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fpin_change_int_example.html&amp;amp;cp=7_1_4_6_20"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fpin_change_int_example.html&amp;amp;cp=7_1_4_6_20&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;and this&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fpin_change_int_example.html&amp;amp;cp=7_1_4_6_20"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fpin_change_int_example.html&amp;amp;cp=7_1_4_6_20&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Basically I want to generate an event using the interrupt to put the device to sleep- or lets say a counterpart to&amp;nbsp;&lt;span&gt;bsp_event_to_button_action_assign(BTN_ID_RESET,BSP_BUTTON_ACTION_RELEASE,BSP_EVENT_RESET); this function.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What function should be used to associate an interrupt with an event?</title><link>https://devzone.nordicsemi.com/thread/275728?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 22:23:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ff0faae-8b87-44d1-b392-c65b83d9b8ae</guid><dc:creator>RJD</dc:creator><description>&lt;p&gt;Also, my input is a single pulse of Low To High To low of 50 ms.&lt;/p&gt;
&lt;p&gt;I want to read that , generate an event , pass that event to put the device to sleep&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What function should be used to associate an interrupt with an event?</title><link>https://devzone.nordicsemi.com/thread/275727?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 22:18:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a879ef0c-b3e1-4076-b77f-9a2568362d53</guid><dc:creator>RJD</dc:creator><description>&lt;p&gt;Hello Andreas, Thank you for your reply.&lt;/p&gt;
&lt;p&gt;could you please explain me the function line by line or step by step in the code snippet.&lt;/p&gt;
&lt;p&gt;I did go through the links-&amp;nbsp;&lt;/p&gt;
&lt;p&gt;a.)&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v13.0.0%2Fgroup__nrf__drv__gpiote.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v13.0.0%2Fgroup__nrf__drv__gpiote.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;b.)&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fgroup__nrf__drv__gpiote.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fgroup__nrf__drv__gpiote.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;c.)&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Fgroup__nrf__drv__gpiote.html&amp;amp;anchor=ga00970227fc2c393fbbc71b3d362b58c2"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Fgroup__nrf__drv__gpiote.html&amp;amp;anchor=ga00970227fc2c393fbbc71b3d362b58c2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But I didnt understand anything properly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, I wanted to know how to generate an event and associate it with the pins as I didnt understand anything.&lt;/p&gt;
&lt;p&gt;I would like to request you to kindly please not provide links with just 1 line explanations, but brief explanations as my knowledge is less. If required kindly please also provide links to tutorials or explanations needed to be read beforehand.&lt;/p&gt;
&lt;p&gt;I apologize if I am sounding rude, it was not the intention, but to give you a better idea in order to assist me.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also how does this line work-&amp;nbsp;nrf_drv_gpiote_in_init(PIN_IN, &amp;amp;in_config, in_pin_handler); ?&amp;nbsp;&lt;span&gt;&amp;nbsp;Please explain in brief&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As in_pin_handler is a function and also not of type&amp;nbsp;&amp;nbsp;nrfx_gpiote_evt_handler_t&amp;nbsp; &amp;nbsp;but void ?&lt;span&gt;&amp;nbsp;Please explain in brief&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;And also why does&amp;nbsp;&lt;span&gt;nrf_drv_gpiote_in_init does throw an error when in_pin_handler is called on being of a void type and not&amp;nbsp;nrfx_gpiote_evt_handler_t .?&amp;nbsp;&amp;nbsp;Please explain in brief&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Q2- How are the parameters being passed to&amp;nbsp;in_pin_handler in&amp;nbsp;nrf_drv_gpiote_in_init?&amp;nbsp;&amp;nbsp;Please explain in brief&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Q3- How and where are the &amp;quot;action&amp;quot; parameter being generated&amp;nbsp; and passed? Please explain in brief.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Q4- Also how to associate the action(function name(s) too) with an event to put the device to sleep or any other event I want to use it for?&amp;nbsp;Please explain in brief.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;tatic void gpio_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

    err_code = nrf_drv_gpiote_out_init(PIN_OUT, &amp;amp;out_config);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    in_config.pull = NRF_GPIO_PIN_PULLDOWN;

    err_code = nrf_drv_gpiote_in_init(PIN_IN, &amp;amp;in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_IN, true);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What function should be used to associate an interrupt with an event?</title><link>https://devzone.nordicsemi.com/thread/275376?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2020 13:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2109d2b6-b2d8-46e9-9596-05e519003782</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Check out the pin change example in the nRF5 SDK:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/pin_change_int_example.html?cp=7_1_4_6_20"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/pin_change_int_example.html?cp=7_1_4_6_20&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What function should be used to associate an interrupt with an event?</title><link>https://devzone.nordicsemi.com/thread/275214?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2020 21:06:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc3ddb50-2ced-4887-a05b-73299cb57144</guid><dc:creator>RJD</dc:creator><description>&lt;p&gt;I wanted something similar to the&amp;nbsp; bsp_event_to_button_action_assign(BTN_ID_RESET,BSP_BUTTON_ACTION_RELEASE,BSP_EVENT_RESET);&lt;/p&gt;
&lt;p&gt;from pwr_mgmt example, but to read from a high pulse.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>