<?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>long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60677/long-spi-communication-unreliable</link><description>Hi teams, 
 I have build custom board connected to ethernet via ENC28J60 ethernet controller. 
 It uses SPI communication with ENC28J60, but some strange behaviour during bulk TX/RX. 
 Please see the following codes. 
 
 These codes are extracted my data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 May 2020 06:55:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60677/long-spi-communication-unreliable" /><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/251600?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 06:55:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9decc094-a65f-4ba7-a2a9-1ce8d5f151d7</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;After I tried to change transfer size, found my mistake eventually.&lt;/p&gt;
&lt;p&gt;Because SPI transfer length is limited to uint8_t, every transfers should break into several ones less than 256.&lt;/p&gt;
&lt;p&gt;So, the following codes works fine. Thanks, Edvin.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    for (int i = 0; i &amp;lt; len; i += UINT8_MAX) {
        nrf_drv_spi_xfer_desc_t datadesc = NRF_DRV_SPI_XFER_RX(buf + i, len - i &amp;gt; UINT8_MAX ? UINT8_MAX : len - i);
        APP_ERROR_CHECK(nrf_drv_spi_xfer(&amp;amp;spi, &amp;amp;datadesc, 0));
    }
...
    for (int i = 0; i &amp;lt; len; i += UINT8_MAX) {
        nrf_drv_spi_xfer_desc_t datadesc = NRF_DRV_SPI_XFER_TX(buf + i, len - i &amp;gt; UINT8_MAX ? UINT8_MAX : len - i);
        APP_ERROR_CHECK(nrf_drv_spi_xfer(&amp;amp;spi, &amp;amp;datadesc, 0));
    }
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/251092?ContentTypeID=1</link><pubDate>Thu, 21 May 2020 02:04:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d398e54d-4cfe-41a6-9309-fcdf8e099c9c</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;With quite a long term testing, my current codes is proven to quite reliable/stable.&lt;/p&gt;
&lt;p&gt;Still massive transfer in single shot is not working, and it easily caused ENC28J60 chip to gone, and it makes hard to analyze the problem with logic analyzer.&lt;/p&gt;
&lt;p&gt;It seems to be happened whenever I tried to send/receive hundreds of bytes with nrfx_spim_xfer().&lt;/p&gt;
&lt;p&gt;Still, I have a interest in this issue, but have another higher priority problems to solve.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll test with increasing the single transfer size, after I can make spare time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/247340?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2020 12:37:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03534645-c7fc-4723-8e84-c0f3e7e89642</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;First, I&amp;#39;ll explain the problem situation.&lt;/p&gt;
&lt;p&gt;The ENC28J60 is the ethernet controller communicated with SPI, and I made driver for it.&lt;/p&gt;
&lt;p&gt;It works fine, but sometimes (very rare, once per a day) the communcation causes problem.&lt;/p&gt;
&lt;p&gt;I made a small extra code to compare SPI sent data to re-read data, and it does not match.&lt;/p&gt;
&lt;p&gt;That is why I try to make sure the SPI communication is working perfectly.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Second, the actual work function is nrfx_spim_xfer() and NRFX_CHECK(NRFX_SPIM_EXTENED_ENABLED) is false.&lt;/p&gt;
&lt;p&gt;Since I am using Mesh SDK, this setting may be default. SDK version is 16.0.0.0 &amp;amp; Mesh SDK is 4.0.0.&lt;/p&gt;
&lt;p&gt;I tested with 52833 DK, and now I also have custom board based on it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Third, currently I am on longivity test with my new custom board.&lt;/p&gt;
&lt;p&gt;At first glance, the error rate seems to be greatly reduced, but not sure yet.&lt;/p&gt;
&lt;p&gt;Still the single burst transfer is not working, and when I checked with analyzer, I couldn&amp;#39;t find difference between the good/bad codes. I&amp;#39;ll investigate further later.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/247021?ContentTypeID=1</link><pubDate>Tue, 28 Apr 2020 09:34:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d7702ae-f499-4751-865a-ab6b7b4965a5</guid><dc:creator>Edvin</dc:creator><description>[quote user="choehyunho"]The disabled block fails with various errors. Maybe incorrect data sent/received.[/quote]
&lt;p&gt;&amp;nbsp;Ok. You need to check using a logic analyzer whether the data that is sent is the same that is on the gpios. Perhaps you can give an example of an error. What are you trying to send, and what is being received?&lt;/p&gt;
&lt;p&gt;What SDK version do you use? And what modules do you use? What functions are being called inside nrf_drv_spi_xfer()?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nrfx_spim_xfer() or&amp;nbsp;nrfx_spi_xfer()?&lt;/p&gt;
&lt;p&gt;What does&amp;nbsp;NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED) return?&lt;/p&gt;
&lt;p&gt;I would continue to dig into this, but there are quite a few options. Why don&amp;#39;t you tell us what the function calls that are being called inside nrf_drv_spi_xfer()? This depends on your sdk_config.h settings.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is this a large problem? Why not just use the implementation that works?&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t really have a lot to work with here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/246923?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 16:34:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b062fefc-6308-4cc8-8bfa-60c04dfce44a</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;It returns NRF_SUCCESS. Otherwise, the code would block because of APP_ERROR_CHECK().&lt;/p&gt;
&lt;p&gt;I checked SPI signals at the early stage of development for simple register access and found nothing strange. (My scope is not so fully capable for triggering/capturing this burst read/write, because this transfer will be started after several small register accesses. Anyway, I&amp;#39;ll try to check whether some different pattern shows between good/bad cases.)&lt;/p&gt;
&lt;p&gt;And nRF52 DK and my custom board shows the same behavior, and changing SPI frequency to lower/lowest also shows no difference.&lt;/p&gt;
&lt;p&gt;Again, my functions send/receive hundreds of bytes on SPI line in single transfer.&lt;/p&gt;
&lt;p&gt;Isn&amp;#39;t it suitable using single nrf_drv_spi_xfer() on this purpose?&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t never suffered from this kind of problem in different platform.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/246862?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 13:11:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:973af7bc-38cd-495f-ae80-5cb3d2cf9771</guid><dc:creator>awneil</dc:creator><description>[quote userid="88182" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable/246775"]The extra delay with for{} loop may caused difference, but normally it should not[/quote]
&lt;p&gt;Shouldn&amp;#39;t it?&lt;/p&gt;
&lt;p&gt;If removing the extra delays makes it &lt;em&gt;too fast&lt;/em&gt; - that&amp;nbsp;would explain it ...&lt;/p&gt;
&lt;p&gt;Again:&lt;/p&gt;
[quote userid="6462" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable/246721"]&lt;b&gt;Have you used a scope or analyser to see what&amp;#39;s happening on the wire?&lt;/b&gt;[/quote]
&lt;p&gt;and&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable/246852"]Have you tried analyzing the SPI wires when using this block? What does it look like compared to the other block[/quote]
&lt;p&gt;we don&amp;#39;t have access to your hardware - so only &lt;em&gt;&lt;strong&gt;you&lt;/strong&gt; &lt;/em&gt;can do that!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/246852?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 12:59:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39fd5e94-7802-4bc4-baf1-d19783059216</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You say that the #if 0 block doesn&amp;#39;t work. Does&amp;nbsp;nrf_drv_spi_xfer() return something other than 0 (NRF_SUCCESS) when you use this block? Have you tried analyzing the SPI wires when using this block? What does it look like compared to the other block?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/246775?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 11:13:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86474909-96b5-40f9-883e-3db75586ccb2</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;First, I admit that I missed one thing to explain.&lt;/p&gt;
&lt;p&gt;This SPI connection is made with spi_config.ss_pin&amp;nbsp;&amp;nbsp; = NRF_DRV_SPI_PIN_NOT_USED;.&lt;/p&gt;
&lt;p&gt;It is because transmitting single byte command and transmitting multple bytes immediately cannot be expressed with single nrf_drv_spi_xfer() call.&lt;/p&gt;
&lt;p&gt;So, I first lower SS pin as GPIO output, and after transfer, up it.&lt;/p&gt;
&lt;p&gt;With this condition, the two codes SHOULD BE EXACTLY THE SAME, AFAIK.&lt;/p&gt;
&lt;p&gt;The extra delay with for{} loop may caused difference, but normally it should not, if the nrf_drv_spi_xfer() is properly made.&lt;/p&gt;
&lt;p&gt;So, does it mean nrf_drv_spi_xfer() for multiple bytes has timing bug?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/246721?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 09:01:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83132dcb-0266-4b20-aa23-b1fd614d6dfe</guid><dc:creator>awneil</dc:creator><description>[quote userid="88182" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable/246702"]The disabled block fails with various errors[/quote]
&lt;p&gt;You need to quantify that!&lt;/p&gt;
&lt;p&gt;A key part of debugging is getting a proper handle of what is actually going wrong!&lt;/p&gt;
&lt;p&gt;Have you used a scope of analyser to see what&amp;#39;s happening on the wire?&lt;/p&gt;
[quote userid="88182" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable/246702"]the active block is working fine[/quote]
&lt;p&gt;So why not just do that?&lt;/p&gt;
&lt;p&gt;The obvious difference at first sight is that one does it as a single transaction, but the other as individual bytes - so the timing is clearly going to be different. And, perhaps, the use of the Slave Select ... ?&lt;/p&gt;
[quote userid="88182" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable/246702"]Which one is sending/receiving (buf + 1) numbers of data[/quote]
&lt;p&gt;That&amp;#39;s not what I said.&lt;/p&gt;
&lt;p&gt;But I misread the code anyhow: I thought it said &amp;#39;1&amp;#39; - not &amp;#39;i&amp;#39; - so&amp;nbsp;ignore that comment!&lt;/p&gt;
&lt;p&gt;Sorry.&lt;/p&gt;
&lt;p&gt;But maybe avoid the use of single-letter variable names.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/246702?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 08:25:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:315d7726-9d78-436b-8900-24025d545dcc</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;The above codes are extracted from my actual driver code.&lt;/p&gt;
&lt;p&gt;The disabled block fails with various errors. Maybe incorrect data sent/received.&lt;/p&gt;
&lt;p&gt;In the other hands, the active block is working fine.&lt;/p&gt;
&lt;p&gt;This is why I am asking, and why the single bulk transfer is working differently with multiple single transfers.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I cannot understand what you mean. Which one is sending/receiving (buf + 1) numbers of data?&lt;/p&gt;
&lt;p&gt;Give your great answer for me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: long SPI communication unreliable</title><link>https://devzone.nordicsemi.com/thread/246618?ContentTypeID=1</link><pubDate>Sat, 25 Apr 2020 09:55:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96b13449-b03b-40ae-9e52-9dcdc3bdfb06</guid><dc:creator>awneil</dc:creator><description>[quote userid="88182" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable"]some strange behaviour[/quote]
&lt;p&gt;Would you care to be a little less vague?&lt;/p&gt;
[quote userid="88182" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable"]it does not work[/quote]
&lt;p&gt;&lt;a href="http://www.catb.org/esr/faqs/smart-questions.html#code"&gt;http://www.catb.org/esr/faqs/smart-questions.html#code&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What testing / debugging / investigation have &lt;em&gt;&lt;strong&gt;you&lt;/strong&gt; &lt;/em&gt;done to find the problem ?&lt;/p&gt;
&lt;p&gt;What have you found so far ?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.avrfreaks.net/comment/2418156#comment-2418156"&gt;https://www.avrfreaks.net/comment/2418156#comment-2418156&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;EDIT&lt;/p&gt;
[quote userid="88182" url="~/f/nordic-q-a/60677/long-spi-communication-unreliable"]The #if 0 blocks should not be different from active ones[/quote]
&lt;p&gt;Well, one key difference is that one uses &amp;#39;buf&amp;#39; and the other &amp;#39;buf+1&amp;#39; ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>