<?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>Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18559/understanding-gpiote-better</link><description>I&amp;#39;m using interrupts on nRF for the first time and have some trouble wrapping my head around / struggling with uncertainty in how to use the interrupts/GPIOTE efficiently. I&amp;#39;d really appreciate some input. My previous experience with using interrupts</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Jan 2017 11:30:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18559/understanding-gpiote-better" /><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71633?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2017 11:30:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14404f5e-b966-48b8-b1bf-688d1aecb6e9</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;Yes. Thank you :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71632?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2017 11:24:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b677dac-74aa-43f8-bad7-96b6a1f0cb86</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erltot, so the issue is fixed ?
A small tip, if you define DEBUG or add DEBUG into the C/C++ preprocessor symbols, and add a breakpoint inside app_error_fault_handler(), you can find out the line number and the filename of the code that caused the issue inside &amp;quot;info&amp;quot;. Error code 8 meaning NRF_ERROR_INVALID_STATE. Matched with what you figured out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71629?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2017 11:11:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7368e362-9ac0-4f30-af7e-0eb7e5df74da</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;It seems this problem has nothing to do with SPI but rather that nrf_drv_gpiote_init() got called twice, m bad.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71631?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2017 10:27:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:660103b8-7f36-4d70-9139-6d49b7a911fa</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;in app_error_weak.c, __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)&lt;/p&gt;
&lt;p&gt;I get error code 8 when trying to init gpiote 0x20006BD8&lt;/p&gt;
&lt;p&gt;my gpiote init function looks like this, call it for the pin used for external detection, and again for SPI MISO pin&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void gpio_event_init(uint8_t pin, nrf_gpio_pin_pull_t pullcfg, bool enable){
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
    
    in_config.pull =  pullcfg;
    err_code = nrf_drv_gpiote_in_init(pin, &amp;amp;in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);
    if(enable) nrf_drv_gpiote_in_event_enable(pin, true);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I comment out the initialization of the SPI MISO pins call, I get no errors&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71630?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2017 09:51:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac194e0f-fec5-4eb1-9606-9c056462cd8a</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Please describe the issue you have. As I mentioned, there is no return from nrf_drv_gpiote_in_event_enable(pin, true); / nrf_drv_gpiote_in_event_disable(pin); , how and where could you get NRF_ERROR_INVALID_STATE  ?
I don&amp;#39;t think you need to do anything else beside nrf_drv_gpiote_in_event_disable() to disable interrupt for that pin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71628?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2017 09:05:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2cbea511-18f0-4391-ad20-ef75319f2279</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;Hung Bui: I still have some issues with the SPI communcation; As I wrote in bullet point 4 above, MISO needs to have interrupt attached for a short time until the peripheral pulls it low to indicate it is ready,
It seems like switching between interrupt and SPI functionality on the same pin creates some problems. Do I completely have to disable the modules or something?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71626?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 13:47:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e176c5c0-ad5b-41f7-ae59-a526b764ebc1</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;Yes, you are right :) Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71625?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 13:43:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f9aba77-1636-41c9-8974-5f76f009cb5b</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I think you need to get to know the way BLE works. You can have a look &lt;a href="https://devzone.nordicsemi.com/blogs/841/bluetooth-smart-and-the-nordics-softdevices-part-2/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The BLE connection is kept by the central periodically send one packet and expect the peripheral to receive  and send a packet back, just so both sides know that the other is still there and acknowledge. We call this connection events. Connection events happen periodically, even when there is no data or command need to be transmitted (except for Slave latency period).&lt;/p&gt;
&lt;p&gt;So, in our implementation of the softdevice, the CPU is already enter sleep mode between connection event and wakeup every connection event. The CPU will receive any data from the central. You can catch the event caused by BLE, it&amp;#39;s usually in on_ble_evt(). The list of event can be found in ble_gap-h, ble_gatt.h, etc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71627?ContentTypeID=1</link><pubDate>Fri, 06 Jan 2017 13:07:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dac1240e-4c55-4a21-ae22-81a27801a7f7</guid><dc:creator>erltot</dc:creator><description>&lt;p&gt;Hi Hung and thanks for your reply.&lt;/p&gt;
&lt;p&gt;I use the interrupt to detect an external event that is not supposed to happen until the device is connected to a BLE master.&lt;/p&gt;
&lt;p&gt;I mean sleep with keeping the connection with the master.&lt;/p&gt;
&lt;p&gt;If I need to wake it from deep sleep, do I need a button or similar, or is there a way to wake it from a BLE event?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Understanding GPIOTE better</title><link>https://devzone.nordicsemi.com/thread/71624?ContentTypeID=1</link><pubDate>Fri, 23 Dec 2016 11:57:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa9a35c0-31eb-4d4f-b0a3-239c0f5b7700</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Erltot,&lt;/p&gt;
&lt;p&gt;Please be noted that you can always use the register directly if needed. The driver we provided in the SDK is just for  your convenience, covering board use cases.&lt;/p&gt;
&lt;p&gt;But I don&amp;#39;t see any reason the driver is not suitable for your need.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure I fully understand your description. Why do you have to set an interrupt when the device is paired ? Is paired meaning connected ? What exactly is &amp;quot;going to sleep&amp;quot; ? It&amp;#39;s deep sleep mode or simply put CPU to sleep and keep the connection&lt;/p&gt;
&lt;p&gt;nrf_drv_gpiote_out_init() is to configured a pin as OUTPUT and if there is a task configured for the pin. This is not related to input pin.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t understand this &amp;quot; Is there only certain things that can be done inside the in_pin_handler event? Should I instead go for setting flags and do the handling in the main loop?&amp;quot;&lt;/p&gt;
&lt;p&gt;You can do what ever you want in the interrupt handler, but you will block other activity with same priority level when you are inside the interrupt handler.&lt;/p&gt;
&lt;p&gt;If you are using the driver, you don&amp;#39;t have to access the register directly, simply call nrf_drv_gpiote_in_event_disable(pin) will disable that pin&amp;#39;s interrupt.&lt;/p&gt;
&lt;p&gt;nrf_drv_gpiote_in_event_enable() won&amp;#39;t return anything, how could you get NRF_ERROR_INVALID_STATE  ?&lt;/p&gt;
&lt;p&gt;You can use same interrupt handler for different pin (then you would need to check which pin causing the interrupt in the argument), or you can use different handler for each pin interrupt.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>