<?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 Tx &amp;amp; Rx failure</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/31241/spi-tx-rx-failure</link><description>Hi DevZone, 
 
 I am doing my project base on SDK 14.2.0 example spi. I modified the PIN according to Arduino PIN map and connected the nRF52480 Preview DK with Arduino Uno. When I run spi example program, Arduino board does receive the data over SPI</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Mar 2018 04:17:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/31241/spi-tx-rx-failure" /><item><title>RE: SPI Tx &amp; Rx failure</title><link>https://devzone.nordicsemi.com/thread/123538?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 04:17:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf796e8f-4072-4375-9c24-6b1909486e00</guid><dc:creator>Ree Wang</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes. I see Transfer complete... I find some mistake in my Arduino SPI slave code. I have updated, then it can receive data from nRF52 DK. Transfer from master to slave is working well now. But still not working for slave to master.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since this questions of this ticket is solved, I would like to close it. I have create another ticket for slave to master transfer issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/31283/spi-master-cannot-receive-spi-slave-response"&gt;devzone.nordicsemi.com/.../spi-master-cannot-receive-spi-slave-response&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you very much for your help!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Tx &amp; Rx failure</title><link>https://devzone.nordicsemi.com/thread/123465?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 14:48:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c937b7d-0a68-4380-8253-6f476169b29b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Do you still see &amp;quot;Transfer completed.&amp;quot; on the RTT terminal&amp;nbsp;from the nRF52840? You did connect slave select line to Arduino as well? Could you write exact pins connected from what to what (SS, SCK, MISO, MOSI)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Tx &amp; Rx failure</title><link>https://devzone.nordicsemi.com/thread/123387?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 09:52:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0d88cc2-6b8f-484d-94cc-20c38b47169d</guid><dc:creator>Ree Wang</dc:creator><description>&lt;p&gt;I am using nRF52480 Preview Development Kit. When I send more than one bytes, for example:&lt;/p&gt;
&lt;p&gt;uint8_t tx_data[] = {5,1};&lt;br /&gt; uint8_t dummy_receive[] = {0,0};&lt;br /&gt; APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, tx_data, 2, dummy_receive, 2));&lt;/p&gt;
&lt;p&gt;I still could not see the log in Arduino side.&lt;/p&gt;
&lt;p&gt;Below is arduino code I am used. The original code can be find in the link:&amp;nbsp;&lt;a id="LPlnk260478" href="https://arduino.stackexchange.com/questions/16348/how-do-you-use-spi-on-an-arduino" rel="noopener noreferrer" target="_blank"&gt;https://arduino.stackexchange.com/questions/16348/how-do-you-use-spi-on-an-arduino&lt;/a&gt;&lt;/p&gt;
&lt;pre class="lang-C++ prettyprint prettyprinted"&gt;&lt;code&gt;&lt;span class="com"&gt;&lt;br /&gt;// what to do with incoming data&lt;/span&gt;&lt;span class="pln"&gt;
&lt;/span&gt;&lt;span class="kwd"&gt;volatile&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="kwd"&gt;byte&lt;/span&gt;&lt;span class="pln"&gt; command &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;0&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;

&lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pln"&gt; setup &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;
  &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;
  Serial.begin(9600);
  &lt;/span&gt;&lt;span class="com"&gt;// have to send on master in, *slave out*&lt;/span&gt;&lt;span class="pln"&gt;
  pinMode&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;MISO&lt;/span&gt;&lt;span class="pun"&gt;,&lt;/span&gt;&lt;span class="pln"&gt; OUTPUT&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;

  &lt;/span&gt;&lt;span class="com"&gt;// turn on SPI in slave mode&lt;/span&gt;&lt;span class="pln"&gt;
  SPCR &lt;/span&gt;&lt;span class="pun"&gt;|=&lt;/span&gt;&lt;span class="pln"&gt; _BV&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;SPE&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;

  &lt;/span&gt;&lt;span class="com"&gt;// turn on interrupts&lt;/span&gt;&lt;span class="pln"&gt;
  SPCR &lt;/span&gt;&lt;span class="pun"&gt;|=&lt;/span&gt;&lt;span class="pln"&gt; _BV&lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;SPIE&lt;/span&gt;&lt;span class="pun"&gt;);&lt;/span&gt;&lt;span class="pln"&gt;

  &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;  &lt;/span&gt;&lt;span class="com"&gt;// end of setup&lt;/span&gt;&lt;span class="pln"&gt;


&lt;/span&gt;&lt;span class="com"&gt;// SPI interrupt routine&lt;/span&gt;&lt;span class="pln"&gt;
ISR &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;SPI_STC_vect&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;
  &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;
  &lt;/span&gt;&lt;span class="kwd"&gt;byte&lt;/span&gt;&lt;span class="pln"&gt; c &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; SPDR&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;

  &lt;/span&gt;&lt;span class="kwd"&gt;if (command==1)&lt;br /&gt;&lt;/span&gt;&lt;span class="pln"&gt;
      SPDR &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; c -5&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;  &lt;/span&gt;&lt;span class="com"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="pln"&gt;      Serial.print(&amp;quot;rx:);&lt;br /&gt;      Serial.println(c, Hex); 
      &lt;/span&gt;&lt;span class="kwd"&gt;break&lt;/span&gt;&lt;span class="pun"&gt;;&lt;/span&gt;&lt;span class="pln"&gt;

  &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;  &lt;/span&gt;&lt;span class="com"&gt;// end of interrupt service routine (ISR) SPI_STC_vect&lt;/span&gt;&lt;span class="pln"&gt;

&lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pln"&gt; loop &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="kwd"&gt;void&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;
  &lt;/span&gt;&lt;span class="pun"&gt;{&lt;/span&gt;&lt;span class="pln"&gt;

  &lt;/span&gt;&lt;span class="com"&gt;// if SPI not active, clear current command&lt;/span&gt;&lt;span class="pln"&gt;
  &lt;/span&gt;&lt;span class="kwd"&gt;if&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;digitalRead &lt;/span&gt;&lt;span class="pun"&gt;(&lt;/span&gt;&lt;span class="pln"&gt;SS&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="pun"&gt;==&lt;/span&gt;&lt;span class="pln"&gt; HIGH&lt;/span&gt;&lt;span class="pun"&gt;)&lt;/span&gt;&lt;span class="pln"&gt;
    command &lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="lit"&gt;0&lt;/span&gt;&lt;span class="pun"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="pln"&gt;  else command = 1;
  &lt;/span&gt;&lt;span class="pun"&gt;}&lt;/span&gt;&lt;span class="pln"&gt;  &lt;/span&gt;&lt;span class="com"&gt;// end of loop&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Tx &amp; Rx failure</title><link>https://devzone.nordicsemi.com/thread/123380?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 09:32:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfe5767c-b0a5-4f02-9e6c-096fd19b30a2</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I tested with P1.12-P1.15 pins as well and I&amp;#39;m still seeing data being transmitted. Have you tried sending more bytes? What does the Arduino SPI slave expect? Will it print logs on any data received? Do you have a link to the code of the Arduino example? I would really recommend getting a logic analyzer for debugging issues like this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Tx &amp; Rx failure</title><link>https://devzone.nordicsemi.com/thread/123375?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 09:20:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fe08ecf-f1ea-4fb2-8840-8439ec934703</guid><dc:creator>Ree Wang</dc:creator><description>&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;I connected nRF DK and Arduino Uno. I flashed Arduino with a Arduino SPI Slave program. I run nRF SDK spi on nRF DK, I see the Arduino print the log when nRF DK transfer data to Arduino. However, when I run my code, Arduino doesn&amp;#39;t print log.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t have a logic analyzer...&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;In Arduino board, the SPI pins are 10,11,12,13. Corresponding to nRF52840 Preview DK, they are p1.12, p1.13, p1.14,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Tx &amp; Rx failure</title><link>https://devzone.nordicsemi.com/thread/123370?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 08:58:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:684bcbbe-e149-479c-bdb5-03a23e17425c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I treied your code and can see data being output on MOSI line. How are you seeing that the Arduino does not receiving the data? Have you checked the SPI bus lines using a logic analyzer, to see if anything is sendt?&lt;/p&gt;
&lt;p&gt;Note &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52840.EngA.errata/anomaly_840_58.html?cp=2_0_1_2_1_5"&gt;this errata&lt;/a&gt; if you are using Eng A revision of nRF52840, with a single byte being sendt using SPI (with EasyDMA enabled).&lt;/p&gt;
[quote user=""] I modified the PIN according to Arduino PIN[/quote]
&lt;p&gt;Which pins did you use?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>