<?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 SPI after disable SD</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11307/using-spi-after-disable-sd</link><description>Hello, 
 I have got a problem with use SPI. I get hard fault after call spi_master_open(), exactly when sd_nvic_ClearPendingIRQ function is call.
This situation is so specific because i use SD at the begining and after that i disable it and try to use</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 17 Jan 2016 14:15:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11307/using-spi-after-disable-sd" /><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42544?ContentTypeID=1</link><pubDate>Sun, 17 Jan 2016 14:15:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bda7b42e-91fc-4213-8587-72de2b229af2</guid><dc:creator>michalmmz</dc:creator><description>&lt;p&gt;Thanks for bouth of you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42543?ContentTypeID=1</link><pubDate>Fri, 15 Jan 2016 01:28:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5b2d2cd-8d7e-49a4-9886-c92705e4fe8b</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Any sd_* function calls into the softdevice so they will all fail if you&amp;#39;re building for softdevice use but have it disabled. So you&amp;#39;d need to modify them all. In the case of the pending IRQ clear, that&amp;#39;s easy, however things like sd_nvic_critical_region_* are not, because those you really do want to call into the softdevice.&lt;/p&gt;
&lt;p&gt;That gives you two options, either you use the function sd_softdevice_is_enabled() everywhere you &amp;#39;re just about to call an sd_ function and call the equivalent NVIC function (or nothing at all), or just leave the softdevice enabled. Actually 3 options, you could also just write your own SPI driver to do what you need if the changes to the standard one are too extensive.&lt;/p&gt;
&lt;p&gt;for the critical enter/exit, you can decide whether you need that at all if the softdevice isn&amp;#39;t enabled, you may not. If you do, then just disable IRQs and enable them again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42542?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2016 21:42:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c40fc23e-1d32-49ea-89d3-c070b4e377de</guid><dc:creator>michalmmz</dc:creator><description>&lt;p&gt;Thank you for answer, but what with other functions in spi_master like sd_nvic_critical_region_enter/exit()?
Do i need to change it or delete?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42541?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2016 23:52:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f87bcaad-2b3a-4095-bb89-e4cdb40a75e7</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;Didn&amp;#39;t know that RK, thanks for clarification!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42540?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2016 23:15:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cd475ce-9976-4d19-8dfd-513fb1f3b787</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;&amp;quot;because softdevice restricts direct access to NVIC (and lots more) and you cannot use it directly.&amp;quot;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s actually not true. The softdevice doesn&amp;#39;t restrict access to the NVIC, and no-longer actually restricts access to much else since recent revisions. Calling via the sd_NVIC_* function just does an extra check that you&amp;#39;re not trying to fiddle with an interrupt the softdevice is using. If you know you&amp;#39;re not, and the SPI isn&amp;#39;t used by the softdevice, it&amp;#39;s fine to call the NVIC_ routines directly, and faster too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42539?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2016 23:12:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6d6468a-47fd-4340-b045-db46ae4b8379</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Probably because you were using the &lt;code&gt;nosd&lt;/code&gt; stubs for those functions which are provided in the SDK for simple source compatibility when a softdevice isn&amp;#39;t in use and just call the NVIC_ routines directly. Now you&amp;#39;re actually using a softdevice you&amp;#39;ll be calling the real sd_ ones from one of the softdevice header files and, as Wojtek correctly says, those you cannot call when the softdevice is disabled as they actually call into it via a SVC call.&lt;/p&gt;
&lt;p&gt;So either don&amp;#39;t disable the softdevice, it doesn&amp;#39;t do very much if there&amp;#39;s no BTLE stuff going on, or change the code to call the NVIC_ function directly, either conditionally on whether the softdevice is enabled or not, or just call it in all cases.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42538?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2016 23:08:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bcf43662-293d-4a47-b9fc-1e6a91a36b6d</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;I didn&amp;#39;t check that, but that may be true  in some cases. Anyway, you should keep with that pattern - sd_ functions only when SD enabled. sd_nvic_ClearPendingIRQ is just alternative to standard CMSIS NVIC_ClearPendingIRQ because softdevice restricts direct access to NVIC (and lots more) and you cannot use it directly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42537?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2016 22:32:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3713a0a7-6a42-4446-8498-2c77b68439ba</guid><dc:creator>michalmmz</dc:creator><description>&lt;p&gt;Earlier i made the same project without SD and function sd_nvic_ClearPendingIRQ was calling. Everything was working fine&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SPI after disable SD</title><link>https://devzone.nordicsemi.com/thread/42536?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2016 22:07:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ebbefa1-fda4-40cd-8a54-406a06db7d85</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;You use SD API calls (the ones that begin with sd_) only when your softdevice is enabled. If you disable your softdevice, you should use non-sd ones, so something like NVIC_ClearPendingIRQ in this case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>