<?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 Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18092/spi-slave-and-ble-on-nrf51822</link><description>Hi, 
 I&amp;#39;m trying to build a SPI Slave &amp;lt;-&amp;gt; BLE bridge, so that everything received over SPI bus is forwarded on BLE and vice versa. In order for the reverse direction to work, the master has to continously pull data from the nRF51822. The problem is that</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 14 Dec 2016 21:42:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18092/spi-slave-and-ble-on-nrf51822" /><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69810?ContentTypeID=1</link><pubDate>Wed, 14 Dec 2016 21:42:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6eda0b0d-4cd8-4147-bac2-d68177ba27da</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;sorry for late answer, but I don&amp;#39;t understand how would you be sure the slave would be able to set the line to low after the master finish transaction if the CPU is occupied by the radio.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m quite novice with Mbed, but would it possible for you to access the SPIS hardware directly ? The way mbed use SPIS on the nRF52 doesn&amp;#39;t take advantage of the EasyDMA feature and the ORC byte. This really limit the usability of the peripheral.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69809?ContentTypeID=1</link><pubDate>Mon, 12 Dec 2016 23:35:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8fd22e9-b445-449b-8a6e-50f9c54dd624</guid><dc:creator>Szabolcs Sz&amp;#233;kelyi</dc:creator><description>&lt;p&gt;I tried radio notifications, and it worked, but it was unsuitable for this purpose since sometimes the CPU was still busy when the notification was inactive.&lt;/p&gt;
&lt;p&gt;What actually worked and ensured a stable communication between the slave and the master was per-transaction flow control. When the slave fills the buffer with data, it also sets a pin high that interrupts the master and enables it to do one transaction. As soon as the slave sees the transaction completed, it reads the data sent by the master from the buffer, sets the interrupt line to low, prepares the next transaction, and interrupts the master again by setting the interrupt line high again. This ensures that whenever the master sends something, there&amp;#39;s a transaction already prepared on the slave side, and no more data is sent by the master before the slave is ready to receive again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69808?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 14:55:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:928a1f67-3b81-48bb-92e9-73232e8e06d1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;It could be a good idea. You can configure to receive radio notification on either ACTIVE, INACTIVE or both. You would need to keep track of this as there is no indication when it&amp;#39;s active or the opposite.
The CPU usually won&amp;#39;t be occupied when the radio is inactive.&lt;/p&gt;
&lt;p&gt;But from my point of view, if you already want to access something mbed is not provide, why don&amp;#39;t just bypass mbed SPI and access the SPIS hardware register directly and simply provide large enough buffer with EasyDMA ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69807?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 14:32:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e57fe80e-258d-4ee2-9497-d9e1e3b1fa78</guid><dc:creator>Szabolcs Sz&amp;#233;kelyi</dc:creator><description>&lt;p&gt;What I&amp;#39;m trying to do now is to have the slave to signal the master on a dedicated signal line before it becomes unable to reply. This way the master can throttle polling it and resume when the signal goes low again indicating the slave&amp;#39;s CPU is available again to reply. I&amp;#39;m using the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.0.0%2Fgroup__ble__radio__notification.html&amp;amp;resultof=%22%62%6c%65%5f%72%61%64%69%6f%5f%6e%6f%74%69%66%69%63%61%74%69%6f%6e%5f%69%6e%69%74%22%20"&gt;nRF5 SDK&amp;#39;s radio notification&lt;/a&gt; to achieve this. Though I&amp;#39;m not sure if this notification will mark exactly those times when the nRF&amp;#39;s CPU is taken over by the BLE stack.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69806?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 14:30:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f3260f3-5ec5-456e-9d1b-35da2fb71818</guid><dc:creator>Szabolcs Sz&amp;#233;kelyi</dc:creator><description>&lt;p&gt;Well, discarding the transaction is not a good idea in this situation since I&amp;#39;m only sending continuously from the master side to poll if the slave has any data to send to the master. The very simple protocol I&amp;#39;m using on the bus is to send the number of bytes available so the master knows how many bytes to pull from the slave after (this can be zero). That&amp;#39;s why I need to keep the bus running all the time, so sending a zero to the slave will allow the master to see if the slave has anything to send to it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69805?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2016 12:54:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02f1c7ff-182c-4b9d-a4da-73d6eac5d278</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;What do you have on the master side on the second transaction ? Would it be the same byte as the first transaction ?&lt;/p&gt;
&lt;p&gt;I am thinking it can discard the transaction if it detects the data from the slave is exactly the same as the last one. But this require you to add 1 bit as the flow control bit. So you only have 7 bit for data.&lt;/p&gt;
&lt;p&gt;Another option is to export the project or use mbed CLI and you can modify the library on your purpose.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69804?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2016 14:00:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e22bb098-bbe8-4ff7-9919-f2a2c26da94e</guid><dc:creator>Szabolcs Sz&amp;#233;kelyi</dc:creator><description>&lt;p&gt;Of course the problem can be solved by using larger send/receive buffers so that the CPU has more time to prepare a reply, but unfortunately that&amp;#39;s not possible with mbed&amp;#39;s SPISlave API.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69803?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2016 13:57:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59844485-1d1b-4118-b9cd-8cd8374eb3b4</guid><dc:creator>Szabolcs Sz&amp;#233;kelyi</dc:creator><description>&lt;p&gt;Yes, it definitely looks like a problem (or feature) related to mbed. In mbed, the send/receive buffers are one byte long. One requirement of a successful transaction is that there&amp;#39;s some data already prepared in the send buffer. This requires calling the SPISlave::relpy() function before the transaction starts. If there&amp;#39;s a reply already prepared in the send buffer, it&amp;#39;s clocked out by the next transaction. But in order to keep the SPI bus running (from mbed&amp;#39;s point of view), SPISlave::reply() has to be called again &lt;em&gt;before&lt;/em&gt; the next transaction. If the master initiates the next transaction before SPISlave::reply() is called on the slave, mbed enters an (undetectable by API) error state when SPISlave::receive() (that tells if there&amp;#39;s a completed transaction) will never again return true unless you call SPISlave::reply(). Then you&amp;#39;re good again until the next missed transaction.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69802?ContentTypeID=1</link><pubDate>Mon, 05 Dec 2016 13:18:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abc5c88c-2061-40d0-859b-9c58d5e62ca2</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I assume this issue comes from the mbed implementation. What exactly happens when it &amp;quot;blocks all data reception until a reply is prepared in the send buffer &amp;quot; ?&lt;/p&gt;
&lt;p&gt;As from the hardware point of view, what i can see is that after you hit &amp;quot;buffer underrun&amp;quot; you will receive OVERREAD event, and on the master it will receive the ORC byte. There shouldn&amp;#39;t be a lock up here.&lt;/p&gt;
&lt;p&gt;Would increasing the RX buffer help avoiding the issue ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69801?ContentTypeID=1</link><pubDate>Sun, 04 Dec 2016 04:46:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4c84065-fed7-428f-a61f-aae7c4584a39</guid><dc:creator>Szabolcs Sz&amp;#233;kelyi</dc:creator><description>&lt;p&gt;The problem was data jam on the SPI bus. Once the SPI peripheral hits a buffer underrun (or &amp;quot;overread error&amp;quot; as the Reference Manual calls it), it becomes essentially unusable under mbed because it blocks all data reception until a reply is prepared in the send buffer. (But since this normally only happens after a reception, this becomes a deadlock). If you fill the buffer with an &amp;quot;unsolicited&amp;quot; reply, the bus will start working again.&lt;/p&gt;
&lt;p&gt;In my case the overrun was caused by the delay introduced by mbed&amp;#39;s BLE implementation. A working BLE radio can block the CPU for as long as 1495 microseconds (that&amp;#39;s not the theoretical maximum, just the highest value I&amp;#39;ve seen). If the SPI peripheral has to execute more than one transaction (as dictated by the master) during the time when the BLE stack (or anything else) uses the CPU, you enter the above deadlock.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Slave and BLE on nRF51822</title><link>https://devzone.nordicsemi.com/thread/69800?ContentTypeID=1</link><pubDate>Thu, 01 Dec 2016 12:14:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13527740-d86f-4bf2-b4d1-56ebc54fe9a9</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Which mbed board are testing with ?&lt;/p&gt;
&lt;p&gt;Some of the thread you quoted was pretty old and may not relevant anymore. For example the CPU is no longer locked up when the radio is active.
It&amp;#39;s hard to tell what went wrong, I&amp;#39;m not very familiar with mbed and it&amp;#39;s also harder to debug with mbed. I would suggest to post the question on mbed forum, in addition. And maybe you can try to export the mbed project to debug offline ?&lt;/p&gt;
&lt;p&gt;PPI and BLE should be fine as long as you don&amp;#39;t use the PPI that the softdevice occupies.&lt;/p&gt;
&lt;p&gt;With the hardware we have, SPIS and BLE should work, worst case is that SPIS will clock out DEF when it can&amp;#39;t access the memory.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>