<?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 master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/31283/spi-master-cannot-receive-spi-slave-response</link><description>Hi DevZone, 
 I am modifying an CAN library for nRF52840 preview DK. In my project, nRF52 preview DK is working as a SPI master and Arduino CAN Bus Shield is working as a SPI slave. 
 
 Before starting test with Arduino CAN Bus shield, I test it with</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 May 2018 15:41:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/31283/spi-master-cannot-receive-spi-slave-response" /><item><title>RE: SPI master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/thread/130864?ContentTypeID=1</link><pubDate>Thu, 03 May 2018 15:41:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b828a42e-8b61-4af7-b947-927f772a885e</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;The problem starts with a simple coding mistake mixing up variables and pointers to variables. You can find some more information on a recent post&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/32670/unable-to-interface-nrf51822-with-lis3dh-accelerometer-using-spi-being-nrf-as-master"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Without changing the intent of your code, start by correctly specifying the send_recv function (lots of ways to do this, just a starting point; this is pretty horrible, I&amp;#39;m just trying to point out the issues with the original code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void spi_send_recv(const nrf_drv_spi_t *spi_master_instance, uint8_t *p_tx_data, uint8_t *p_rx_data,const uint16_t len)
{
 uint32_t err_code = nrf_drv_spi_transfer(spi_master_instance, p_tx_data, len, p_rx_data, len);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Next pass the address of the variables, not the values:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Assuming static const nrf_drv_spi_t SPI_INSTANCE_0 = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);

uint8_t dummy_tx = 0xA0;
 spi_send_recv(&amp;amp;SPI_MASTER_0, &amp;amp;dummy_tx, &amp;amp;dummy_receive, 1);
...
dummy_tx = 0xA0;
 spi_send_recv(&amp;amp;SPI_MASTER_0, &amp;amp;dummy_tx, &amp;amp;i, 1);

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But it would be more usual to just have an array of uint8_t types and send in a single command, unless the CAN device has issues with that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/thread/130721?ContentTypeID=1</link><pubDate>Thu, 03 May 2018 06:42:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4619d783-bd97-401a-a03f-cb184e8c6df3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;have you switched to another SPI module? it has been 2 months and i thought you might have figured out the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/thread/130678?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 22:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e08a3315-90aa-420a-988c-6e97f1f124c8</guid><dc:creator>Ree Wang</dc:creator><description>&lt;p&gt;Hi Renato,&lt;/p&gt;
&lt;p&gt;Have not solved it yet...&amp;nbsp;unfortunately&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/thread/130666?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 19:27:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac099936-01ac-41bc-a540-42d2db5371ce</guid><dc:creator>RenatoMorelli</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/ree-wang"&gt;Ree Wang&lt;/a&gt; &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f603.svg" title="Smiley"&gt;&amp;#x1f603;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Did you manage to solve this spi issue? I am facing something similar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/thread/124247?ContentTypeID=1</link><pubDate>Wed, 14 Mar 2018 00:11:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f37e9cf2-7d79-4a6f-960a-c5482249c6dc</guid><dc:creator>Ree Wang</dc:creator><description>&lt;p&gt;Thanks. I use nRF52840 Preview DK, the SDK is&amp;nbsp; nRF5 SDK v14.2.0. I don&amp;#39;t have logic analyzer... I will check the points you mentioned.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/thread/124202?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 14:57:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1116343f-d137-4a2c-8319-8a57f382626e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Which SDK version are you using and which nRF52 DK are you using? is it 0.10.0 or 0.11.0&lt;/p&gt;
&lt;p&gt;SPI is very extensively used module, So I would be surprised if there are any unknown issues in it. That said.&lt;/p&gt;
&lt;p&gt;Could you take a logic analyzer and compare the two outputs. There might be a deviation in the clocks? different initial values? or default pin pull configuration? hard to say, but logic analyzer should reveal it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/thread/123738?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 15:45:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7a87093-fba1-46fd-8625-b4b21cd2e98b</guid><dc:creator>Ree Wang</dc:creator><description>&lt;p&gt;Thanks. I have tried all 4 modes. But no one can fix the issue...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI master cannot receive SPI slave response</title><link>https://devzone.nordicsemi.com/thread/123714?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 14:15:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aed40f82-65e6-4466-977f-d5334d54a431</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Looks like the SPI mode does not match with what the&amp;nbsp;slave is expecting. Can you please double check the spec of the sensor with what mode it expects SPI data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>