<?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>SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65263/spim3-reads-fail-when-softdevice-enabled</link><description>Hello, 
 I am developing a product that uses an external flash chip and we are using SPIM3 at 32 MHz. In addition we have been attempting to utilize the SoftDevice in order to offer some BLE functionality. But after enabling the SoftDevice (nrf_sdh_enable_request</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 02 Sep 2020 16:54:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65263/spim3-reads-fail-when-softdevice-enabled" /><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/267692?ContentTypeID=1</link><pubDate>Wed, 02 Sep 2020 16:54:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad89b09a-2ee6-4ffe-b2a9-49d27bb3bc99</guid><dc:creator>csulz</dc:creator><description>&lt;p&gt;There are four scenarios on two variables: Jtag Debug board (nrf52840-DK) running program with SEGGER plugged in or not, and softdevice enabled/disabled.&lt;/p&gt;
&lt;p&gt;Debug board Connected - SPIM3 Always works regardless of softdevice&lt;/p&gt;
&lt;p&gt;Debug board disconnected - Softdevice disabled&amp;nbsp; - SPIM3 works.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Debug board disconnected - Softdevice enabled - No clock to SPIM3.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/267534?ContentTypeID=1</link><pubDate>Wed, 02 Sep 2020 07:29:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00e5ead9-e433-4dd1-85ec-c1fadfa2a8a8</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;And the problem only occurs when softdevice is enabled?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t really have any other suggestion than to try and fail a bit, maybe even add SPIM3 to a simple example to check if that works.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/267506?ContentTypeID=1</link><pubDate>Tue, 01 Sep 2020 21:46:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2291668d-3432-497b-915f-ea63d869af89</guid><dc:creator>csulz</dc:creator><description>&lt;p&gt;I tried this, there is no difference. Made both the&amp;nbsp;&lt;span&gt;nrfx_spim_xfer_desc_t&amp;nbsp; struct and&amp;nbsp;nrfx_spim_config_t&amp;nbsp;(for this spim) global and there is no difference.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/267394?ContentTypeID=1</link><pubDate>Tue, 01 Sep 2020 08:43:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:301a97c0-9631-4686-901d-bbd2590b156e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Have you tried to disconnect the external chip, just to verify that SCK is not held low?&lt;/p&gt;
&lt;p&gt;Can you try to make&amp;nbsp;&lt;span&gt;nrfx_spim_xfer_desc_t desc and&amp;nbsp;nrfx_spim_config_t spim_config global or static, in case the compiler is doing some optimization here?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/267310?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 17:25:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22cc5ad6-b4f3-47cf-8dd5-01519a029123</guid><dc:creator>csulz</dc:creator><description>&lt;p&gt;Are you speaking about &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Ferrata_nRF52840_Rev2%2FERR%2FnRF52840%2FRev2%2Flatest%2Fanomaly_840_198.html&amp;amp;cp=3_0_1_0_1_28"&gt;Errata 198&lt;/a&gt;? I will try the suggested solution although I am not sure if that describes my problem. Verified by the oscilloscope the clock does not pulse when the SPIM is supposed to be sending/receiving. I don&amp;#39;t see ANY transmit data, let alone incorrect ones.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/267309?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 17:19:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03855e96-d6a7-4bc2-8d2a-1bb8ece40536</guid><dc:creator>csulz</dc:creator><description>&lt;p&gt;Yes, sorry there is a while loop waiting for the spim_done flag which is set in the spim_event_handler&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;while (!spim_done) {&lt;br /&gt; __WFE();&lt;br /&gt; }&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/267166?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 09:36:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0df7071f-213c-4943-8f59-7434af16f63e</guid><dc:creator>Turbo J</dc:creator><description>[quote userid="79354" url="~/f/nordic-q-a/65263/spim3-reads-fail-when-softdevice-enabled"]I am honestly stumped as to what the SD enable has to do with the SPIM transfer. Any help is appreciated.[/quote]
&lt;p&gt;Have look into the errata sheet!&lt;/p&gt;
&lt;p&gt;SPIM3 has a &lt;em&gt;nasty&lt;/em&gt; DMA bug. The SD probably just makes it more likely to trigger.&lt;/p&gt;
&lt;p&gt;Basically you need to reseve one (or two, depending on usage scenario) complete RAM blocks for SPIM3, so that there is no CPU data access in that block during DMA.&lt;/p&gt;
&lt;p&gt;Together with SD this is a non-trivial linker script/settings modification. The example workaround in the SDK does &lt;em&gt;not&lt;/em&gt; work with SD enabled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/267162?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 09:20:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec7cc8f7-e7af-4c7b-b2d8-308b100d6c71</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I assume you code is somewhat like this (added wait for spim_done):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t tx[4];
memset(tx, 0, sizeof(tx));

tx[0] = W25_JEDEC_ID; // request manufacturing id

nrf_gpio_pin_set(PINNUM_nCSF0); // ensure Flash 0 is not selected
nrf_gpio_pin_set(PINNUM_nCSF1); // ensure Flash 1 is not selected
nrf_gpio_pin_clear(PINNUM_nCSF0); // select Flash 0

nrfx_spim_xfer_desc_t desc = {
.p_tx_buffer = tx,
.tx_length = 4,
.p_rx_buffer = rx,
.rx_length = 4
};

uint32_t ret;

spim_done = false;

ret = nrfx_spim_xfer(&amp;amp;fastspim, &amp;amp;desc, 0);
APP_ERROR_CHECK(ret);

while(!spim_done)
  ;

nrf_gpio_pin_set(PINNUM_nCSF0); // not select Flash 0
nrf_gpio_pin_set(PINNUM_nCSF0); // ensure Flash 0 is not selected
nrf_gpio_pin_set(PINNUM_nCSF1); // ensure Flash 1 is not selected

//rx buffer is then read and compared against expected&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/266830?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 19:27:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2833c6f1-9a2d-44f9-9603-c81dff045f73</guid><dc:creator>csulz</dc:creator><description>&lt;p&gt;I took your advice and brought out the oscilloscope. Triggering on the chip select, with softdevice OFF I can see the clock pulses and data as you would expect. With Softdevice ON I can see the chip select asserted but there is no clock pulses present.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;These pins are initialized like so:&lt;/p&gt;
&lt;p&gt;#define PINNUM_F_MOSI&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;17&lt;/p&gt;
&lt;p&gt;#define PINNUM_F_MISO&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;19&lt;/p&gt;
&lt;p&gt;#define PINNUM_F_SCLK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;nrf_gpio_cfg_output(PINNUM_F_MOSI);&lt;br /&gt; nrf_gpio_cfg_input (PINNUM_F_MISO, NRF_GPIO_PIN_NOPULL);&lt;br /&gt; nrf_gpio_cfg_output(PINNUM_F_SCLK);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/266817?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 17:10:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e09ad80-968e-4b21-9af5-a083659f738b</guid><dc:creator>csulz</dc:creator><description>&lt;p&gt;Also to confuse matters more the program works normally when our board is connected to the nRF52840-DK J-link debugger. So when debugging (using SEGGER) everything works fine but when the device is running on the actual hardware it does not. But when the softdevice code is not included the flash read works correctly.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM3 reads fail when SoftDevice enabled</title><link>https://devzone.nordicsemi.com/thread/266741?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 12:34:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c823672-f523-48b0-8d1d-bc0da0418e9e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I recommend a logic analyzer trace here, to compare with and without softdevice enabled. Just to look at the serial transaction (e.g. is the pins correct, is the MISO and MOSI correct, number of bytes etc) between working and failing.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>