<?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>Trying to understand how SPI Slave should be implemented</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53893/trying-to-understand-how-spi-slave-should-be-implemented</link><description>Greetings! I&amp;#39;m trying to set up an nRF52 board as an SPI slave so that it would receive chunks of data irregularly from the master device (a Raspberry Pi in this case, if it&amp;#39;s important). However, I am not sure if I understand correctly the purpose of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 Nov 2019 05:47:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53893/trying-to-understand-how-spi-slave-should-be-implemented" /><item><title>RE: Trying to understand how SPI Slave should be implemented</title><link>https://devzone.nordicsemi.com/thread/220213?ContentTypeID=1</link><pubDate>Fri, 15 Nov 2019 05:47:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1fbfe12-b7cf-4fd8-b381-256a174bc868</guid><dc:creator>SergeyK</dc:creator><description>&lt;p&gt;Hello! I borrowed a Logic Analyzer, and tried looking at the transactions. I noticed that any errors were also read by LA, so I decided that it&amp;#39;s not the chip&amp;#39;s fault, but I also noticed that timings were kinda weird and not matching whatever I set script to. So I went back to other SPI library, set a speed of 500khz (which was then properly measurable at LA), and it went with no errors.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " height="164" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/4188.spi.png" width="500" /&gt;&lt;br /&gt;&lt;br /&gt;I am still not sure that I understand how exactly SPI transaction works on this level (one that I can see trough LA), _besides_ the obvious data transfer on clock edge, like what &amp;#39;clocked-out&amp;#39; means in nRF52 documentation and what is the purpose of DEF and ORC from my perspective, and what is this small spike on MISO right after CS edge... (I still need to read more articles on SPI).&lt;br /&gt;&lt;br /&gt;But I think that this case is solved - I now know how to make a data transfer from RPi and how to receive it properly on nRF52, and maybe even troubleshoot it a bit with logic analyzer&lt;br /&gt;&lt;br /&gt;Thank you again!&lt;br /&gt;&lt;br /&gt;For future generations: here is my SPI code now&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="python"&gt;import spidev

spi = spidev.SpiDev()

spi.open(0, 0)

spi.max_speed_hz = 500000
spi.mode = 0

recv = spi.xfer2(bytearray(&amp;quot;hello, world&amp;quot;, &amp;quot;utf-8&amp;quot;))
print(&amp;quot;Recieved %s&amp;quot; % bytearray(recv))

spi.close()&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to understand how SPI Slave should be implemented</title><link>https://devzone.nordicsemi.com/thread/218847?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2019 13:33:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7f03737-1a1a-4b3c-be8d-1f7fcce9a6bb</guid><dc:creator>SergeyK</dc:creator><description>&lt;p&gt;Okay, thanks a lot! I think I have some SPI theory to read. I also have few other micro controller boards lying around, will try using them; plus I&amp;#39;ll check it with logic analyzer when I&amp;#39;ll get or borrow one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to understand how SPI Slave should be implemented</title><link>https://devzone.nordicsemi.com/thread/218842?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2019 13:25:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b142ef6-932f-4744-91ca-05c9a638d73d</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>[quote user="SergeyK"]I&amp;nbsp;would really like to hear if my understanding of SPI Slave is correct or if I&amp;#39;m missing something; And what could theoretically be the cause for transfer issues at lower speed.[/quote]
&lt;p&gt;&amp;nbsp;Your understanding is correct. If you want to update the buffer, you call&amp;nbsp;nrfx_spis_buffers_set(), and this is safe to call when the former SPI transaction is done (ie: in the _DONE event of the evt-handler). There isn&amp;#39;t anything that should cause it to misbehave at 500 kHz vs. 1 MHz. If you get an ignored transaction (not setting buffer for instance), it should instead clock out the current content of &amp;quot;DEF&amp;quot; register:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52810/spis.html?cp=3_4_0_5_19_4_34#register.DEF"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52810/spis.html?cp=3_4_0_5_19_4_34#register.DEF&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It should not clock out a partial buffer in that case. That sounds more of a issue on the master side, unless the spi slave buffer is written &amp;quot;mid transfer&amp;quot; by the application firmware, which it does not look like is happening on your side, especially if the test program is that small.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to understand how SPI Slave should be implemented</title><link>https://devzone.nordicsemi.com/thread/218827?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2019 12:50:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e72e2ac-f657-4554-9e2e-215e1246730e</guid><dc:creator>SergeyK</dc:creator><description>&lt;p&gt;Hello!&lt;br /&gt;&lt;br /&gt;I&amp;#39;m planning on getting a logical analyzer, but this won&amp;#39;t happen tomorrow, unfortunately.&lt;br /&gt;&lt;br /&gt;As I said, when I had a speed of 5 * 10^4 (I checked now on 5 * 10^5 and still had same issues), I only received successful read once; afterwards I was either missing some bytes, read some bytes wrong, or both. However, when I set the speed to 10^6, it caused data transmission to be&amp;nbsp;a bit more reliable. I tried sending bytes few dozen times at a different times (after some time of nRF52 running, right after reset, etc.), and I still do receive garbage, but every third time.&lt;br /&gt;&lt;br /&gt;I&amp;nbsp;would really like to hear if my understanding of SPI Slave is correct or if I&amp;#39;m missing something; And what could theoretically be the cause for transfer issues at lower speed.&lt;br /&gt;&lt;br /&gt;Thanks.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to understand how SPI Slave should be implemented</title><link>https://devzone.nordicsemi.com/thread/218416?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2019 07:26:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d646c09c-cd22-45d6-9846-59f506b1d6a8</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you have a logic analyzer so that you can look at the SPI signals on the bus itself?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How often do you read out with the unwanted characters ? Once in a while, or every time?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Trying to understand how SPI Slave should be implemented</title><link>https://devzone.nordicsemi.com/thread/217847?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 20:06:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae2b6174-c53e-4c04-a5d6-eb933c8474f1</guid><dc:creator>SergeyK</dc:creator><description>&lt;p&gt;I have noticed that setting higher speed (50000 -&amp;gt; 1000000) causes transmissions to be more reliable and to occur in a single event more often, which is kinda counter-intuitive for me, but I hope this gives someone a clue to what is going on here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>