<?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>SPI calls and bluetooth send from GPIOTE handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7645/spi-calls-and-bluetooth-send-from-gpiote-handler</link><description>Hello! 
 I have based myself on the ble_app_uart example, taken out the UART bit, and all that remains is the bluetooth functionality. 
 I have also implemented SPI communication which works fine in a Timer and directly in the main loop. 
 However</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 16 Jun 2015 10:30:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7645/spi-calls-and-bluetooth-send-from-gpiote-handler" /><item><title>RE: SPI calls and bluetooth send from GPIOTE handler</title><link>https://devzone.nordicsemi.com/thread/27251?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2015 10:30:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ee5428d-96a2-40ed-bde3-ec3043de36d6</guid><dc:creator>Emil</dc:creator><description>&lt;p&gt;Thanks for your quick answer!&lt;/p&gt;
&lt;p&gt;I thought passing it to the scheduler is smart to not hinder the IRQ and to not cause issues. This is the right design, right?&lt;/p&gt;
&lt;p&gt;There is nothing else in the IRQ handler. My &amp;quot;in_pin_handler&amp;quot; has nothing else than in the code I posted. It seems like my ISP is unstable (wiring problem). Good to know that my code is &amp;quot;clean&amp;quot;!&lt;/p&gt;
&lt;p&gt;However, when I try to connect through the Nordic UART Android I get disconnected as fast as I connect.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define APP_TIMER_MAX_TIMERS            (2 + BSP_APP_TIMERS_NUMBER)                 /**&amp;lt; Maximum number of simultaneously created timers. */
void in_pin_scheduler_func(void *data, uint16_t size)
{	
	uint8_t status = Adxl362_GetStatus();
	UNUSED_VARIABLE(status);

	int16_t x, y, z;
	Adxl362_GetAcceleration(&amp;amp;x, &amp;amp;y, &amp;amp;z);
	//
	sprintf((char *)&amp;amp;m_buffer[0], &amp;quot;%X (%d) - %d,%d,%d&amp;quot;, status, status &amp;amp; (1 &amp;lt;&amp;lt; 6) ? 1 : 0, x,y,z);
	ble_nus_string_send(&amp;amp;m_nus, m_buffer, sizeof(m_buffer));

	//nrf_drv_gpiote_out_toggle(BSP_LED_3);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this correct? I stopped initializing LEDs and buttons as you can see in main ()&lt;/p&gt;
&lt;p&gt;EDIT: The m_buffer was too small for the string. How big strings can I send in one go?&lt;/p&gt;
&lt;p&gt;EDIT2: Found it! BLE_NUS_MAX_DATA_LEN&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI calls and bluetooth send from GPIOTE handler</title><link>https://devzone.nordicsemi.com/thread/27250?ContentTypeID=1</link><pubDate>Tue, 16 Jun 2015 09:14:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0c745e4-90f5-4f93-89e7-a34d8a30bfaf</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Well no it&amp;#39;s not supposed to hardfault, that would be bad.&lt;/p&gt;
&lt;p&gt;Most common cause of hardfault is calling an sd_* function from an interrupt level higher (ie numerically lower) than the SVC call is set up to use, which is 2.&lt;/p&gt;
&lt;p&gt;You&amp;#39;re shuffling the GPIOTE interrupt servicing off to a scheduler routine, ok so what&amp;#39;s in that runs in main thread context, so that shouldn&amp;#39;t be it - you have anything else, anything in a timer handler, GPIOTE handler, any other handler at all which calls any kind of BTLE-related code which ends up calling an sd_* function? If so what&amp;#39;s the priority of the context you&amp;#39;re calling it in, if it&amp;#39;s APP_HIGH, it&amp;#39;s too high and the device will hardfault.&lt;/p&gt;
&lt;p&gt;If not - what&amp;#39;s the exact line of code you&amp;#39;re crashing on?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>