<?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>Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10510/using-gpiote-with-s130-in-the-ble-uart-example</link><description>I&amp;#39;ve been using the ble_app_uart example with S130 on a nRF51 DK board. I wanted to add an interrupt with some GPIO pins. So I added GPIOTE interrupt handler but the compiler returned an error: 
 linking...
._build\nrf51422_xxac_s120.axf: Error: L6200E</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 09 Dec 2015 10:14:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10510/using-gpiote-with-s130-in-the-ble-uart-example" /><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39087?ContentTypeID=1</link><pubDate>Wed, 09 Dec 2015 10:14:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:537fb43d-814e-4a4c-915a-489794772b45</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;Ole, you are a champion!!&lt;/p&gt;
&lt;p&gt;Following your suggestion, I found how to implement the priority in &lt;a href="https://devzone.nordicsemi.com/question/57691/app_scheduler-and-timer1-hardfault/"&gt;https://devzone.nordicsemi.com/question/57691/app_scheduler-and-timer1-hardfault/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The GPIOTE works after I added&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_LOW);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;in the initialisation step, straight after&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  err_code = nrf_drv_gpiote_in_init(AUDIO_STIM_PIN, &amp;amp;event_config, stimulus_handler);
  APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39085?ContentTypeID=1</link><pubDate>Tue, 08 Dec 2015 15:42:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c652b1a6-461e-4c87-a470-c05be589c761</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;I should have thought of this before: The GPIOTE handler is running at &lt;code&gt;APP_PRIORITY_HIGH&lt;/code&gt;, which means that &lt;code&gt;sd_ble_gattc_write(...)&lt;/code&gt; is called at this level. It is not allowed to do SoftDevice calls at APP_PRIORITY_HIGH, and if attempted to do so, the application will run into hardfault. SoftDevice calls have to be made in main context or at &lt;code&gt;APP_PRIORITY_LOW&lt;/code&gt;. I will update my answer if this is correct. Sorry for the late answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39084?ContentTypeID=1</link><pubDate>Sat, 05 Dec 2015 13:15:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d43cff5a-101b-4da3-b47c-1a7931ad466f</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;After pressing the button triggering my gpiote event, I could still step through the code until it reaches line 84 (below) in &lt;code&gt;ble_uart_c.c&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    err_code = sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle,
                                  &amp;amp;m_tx_buffer[m_tx_index].req.write_req.gattc_params);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I select Step Into, it goes to line 160 of arm_startup_nrf51.s&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;HardFault_Handler\
                PROC
                EXPORT  HardFault_Handler         [WEAK]
                B       .
                ENDP
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and then it is stuck.&lt;/p&gt;
&lt;p&gt;I also attempted to use polling. I wrote a function that sends a character to the dongle whenever button press is detected. The function is located in the for loop in the main function (below) and works fine.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for (;;)
{
    power_manage();
	stimulus_polling();
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39082?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2015 13:04:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:939ca94a-5ede-49bd-8f93-d3a09b4e583d</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;You should have gotten the event. You are sure the code is not stuck? Try stopping the execution while in debug after the disconnection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39083?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2015 12:31:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60d0b4ab-c1ae-4f0c-b6eb-644577443116</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;I found 2 places that have &lt;code&gt;BLE_GAP_EVT_DISCONNECTED&lt;/code&gt; event in the project, namely,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;device_manager_central.c&lt;/li&gt;
&lt;li&gt;ble_db_discovery.c&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I placed breakpoints in the switch case for this event. But when the disconnection occurred, the execution did not go to any of these breakpoints.&lt;/p&gt;
&lt;p&gt;Any suggestion where I can detect the event?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39081?ContentTypeID=1</link><pubDate>Thu, 03 Dec 2015 13:56:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:942d622c-ab82-4f42-8681-d2f3325fd89a</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;When you step through the code, the chip will stop and the link will timeout and be lost. Also, the SoftDevice may stop working correctly and cause a hardfault. Therefore step debugging should be approached carefully. If the disconnection is not caused by an error condition you can check the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.api.v1.0.0/structble__gap__evt__disconnected__t.html?resultof=%22%64%69%73%63%6f%6e%6e%65%63%74%22%20%22%72%65%61%73%6f%6e%22%20"&gt;disconnect reason&lt;/a&gt; in &lt;code&gt;BLE_GAP_EVT_DISCONNECTED&lt;/code&gt; event, it should be in &lt;code&gt;p_ble_evt-&amp;gt;evt.gap_evt.params.disconnected.reason&lt;/code&gt;. If you have a spare nRF dongle or a board you can also try the sniffer to see what is going on over the air, see &lt;a href="https://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF-Sniffer/(language)/eng-GB"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39079?ContentTypeID=1</link><pubDate>Thu, 03 Dec 2015 12:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1bbb82c7-4d65-4e9b-9fa6-2ea1cbd716a7</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;That&amp;#39;s the wierd part. There was no error. The LEDs didn&amp;#39;t lit up.&lt;/p&gt;
&lt;p&gt;In debug mode, I could see that pressing the button switch invoked the gpiote event handler and could step through the lines. Suddenly, the red LED on the dongle went blinking - BLE was disconnected. I could still step through the code until it &amp;quot;froze&amp;quot; usually at &lt;code&gt;sd_ble_gattc_write(m_tx_buffer[m_tx_index].conn_handle, &amp;amp;m_tx_buffer[m_tx_index].req.write_req.gattc_params);&lt;/code&gt; or &lt;code&gt;memcpy(p_msg-&amp;gt;req.write_req.gattc_value,p_str,p_str_len);&lt;/code&gt; in &lt;code&gt;ble_uart_c_write_string&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So it never went to &lt;code&gt;app_error_handler&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;EDIT: I commented out the code in the gpiote event handler &lt;code&gt;stimulus_handler&lt;/code&gt;. If the code is running not in the debug mode, pressing the button switch does not make the BLE link disconnected.&lt;/p&gt;
&lt;p&gt;But if the code is running in the debug mode, the BLE link got disconnected after pressing the button.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39080?ContentTypeID=1</link><pubDate>Wed, 02 Dec 2015 13:30:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:daa726da-1b7e-48db-b732-2e75d75d948d</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Any error (leds lit up)? Go into debug and set a breakpoint at &lt;code&gt;while(1)&lt;/code&gt; in &lt;code&gt;app_error_handler&lt;/code&gt;, check the error code, line number and file variables.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39078?ContentTypeID=1</link><pubDate>Wed, 02 Dec 2015 13:19:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5434f91-c057-4368-acce-d4783cd624d7</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;Thanks for that. I just discovered this too after stepping through in Debug.&lt;/p&gt;
&lt;p&gt;I also decided to use another pin (P0.15) and placed another button switch there so that it will call my event handler instead of &lt;code&gt;gpiote_event_handler&lt;/code&gt;. I also had to use the high accuracy option (&lt;code&gt;nrf_drv_gpiote_in_config_t event_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);&lt;/code&gt;). After these two changes and adding the init check (&lt;code&gt;nrf_drv_gpiote_is_init&lt;/code&gt;) that you pointed out, the code worked as original.&lt;/p&gt;
&lt;p&gt;Interestingly, when I pressed the new button, the BLE link was disconnected. The red LED on the dongle changed from on (connected state) to blinking (disconnected). I expected &lt;code&gt;stimulus_handler&lt;/code&gt; to be executed which sent the string &amp;quot;A&amp;quot; to the dongle. If the reset button the DK board is pressed, the BLE link was connected again. But pressing the button disconnected the ink again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39077?ContentTypeID=1</link><pubDate>Wed, 02 Dec 2015 11:46:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5561f3e-c580-4472-868d-6d777bc9cc4e</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Update answer:&lt;/p&gt;
&lt;p&gt;The gpiote driver is already initialized so &lt;code&gt;nrf_drv_gpiote_init()&lt;/code&gt; will return error and either stop the code or reset the chip depending if DEBUG is defined (see the code in &lt;code&gt;app_error_handler(...)&lt;/code&gt;). Change to this code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if(!nrf_drv_gpiote_is_init())
{
    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Update 09.12.2015:&lt;/strong&gt; The GPIOTE handler is running at &lt;code&gt;APP_PRIORITY_HIGH&lt;/code&gt;, which means that &lt;code&gt;sd_ble_gattc_write(...)&lt;/code&gt; is called at this level. It is not allowed to do SoftDevice calls at APP_PRIORITY_HIGH, and if attempted to do so, the application will run into hardfault. SoftDevice calls have to be made in main context or at &lt;code&gt;APP_PRIORITY_LOW&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39074?ContentTypeID=1</link><pubDate>Wed, 02 Dec 2015 11:19:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8ce5384-1f69-4637-a249-8b1e324cf5f4</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;When the main function called &lt;code&gt;gpiote_init&lt;/code&gt;, the DK board did not reach scanning. All 4 LEDs were on.&lt;/p&gt;
&lt;p&gt;Without &lt;code&gt;gpiote_init&lt;/code&gt;, the DK board scanned and could detect the dongle board which was running the periperhal code. Only LED 1 was on.&lt;/p&gt;
&lt;p&gt;How do I check that &lt;code&gt;err_code&lt;/code&gt; does not return &lt;code&gt;NRF_SUCCESS&lt;/code&gt; ?&lt;/p&gt;
&lt;p&gt;I also discovered that if     &lt;code&gt;m_cb.state = NRF_DRV_STATE_INITIALIZED;&lt;/code&gt; is commented out in &lt;code&gt;nrf_drv_gpiote_init&lt;/code&gt;, the code works.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t understand why though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39073?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2015 16:30:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4b969b4-6c9c-4554-9128-73437b667573</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;What do you mean when you say &amp;quot;stopped working&amp;quot;? Do the chip reset (this is the default behaviour if &lt;code&gt;err_code&lt;/code&gt; is not &lt;code&gt;NRF_SUCCESS&lt;/code&gt; in &lt;code&gt;APP_ERROR_CHECK(...)&lt;/code&gt;)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39076?ContentTypeID=1</link><pubDate>Sun, 29 Nov 2015 11:53:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65362f0a-b74a-48cd-8663-376691f43a71</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;Never mind. I managed to get the gpiote event working though it did not respond to a LED task through ppi. That&amp;#39;s for another question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39075?ContentTypeID=1</link><pubDate>Sat, 28 Nov 2015 14:20:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc73dc63-9f2a-4cef-a7c1-9a15ebaf2fbc</guid><dc:creator>Johnson</dc:creator><description>&lt;p&gt;Thank you for the suggestion, Ole Bauck.&lt;/p&gt;
&lt;p&gt;I looked into the gpiote example in SDK 9.0.0. The example only used gpiote task to drive the LED while gpiote event is not included. I tried to add a gpiote event but it did not work.&lt;/p&gt;
&lt;p&gt;Is there any gpiote example that uses gpiote event (e.g. evoked by a button switching the pin fro high to low)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using GPIOTE with S130 in the BLE UART example</title><link>https://devzone.nordicsemi.com/thread/39086?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2015 15:06:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8863435f-a963-4880-ade0-6f2f877ea58b</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;app_button does not use timer for polling in that sense. It uses a timer for a debounce delay after the button has been pushed, see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/lib_button.html?cp=4_1_1_3_5"&gt;here&lt;/a&gt;. The error you are getting is because GPIOTE_IRQHandler is defined in nrf_drv_gpiote.c and in main.c. I would suggest that you use the nrf_drv_gpiote library. Be aware that with the SoftDevice, the delay may be longer than 1 ms while in a connection, see &lt;a href="https://devzone.nordicsemi.com/question/15696/nrf51822-sense-pin-in-port-mode-doesnt-solve-the-gpiote-overconsumption-in-event-mode/?answer=15737#post-id-15737"&gt;here&lt;/a&gt; for more info.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>