<?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 rx problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17002/spi-rx-problem</link><description>Hi guys, 
 I&amp;#39;m having some trouble with an spi flash memory (AT45DB081D) I interfaced on my nrf51 DK. 
 I used the spi master code of nRF5 v.12 SDK as base. I&amp;#39;m using gcc on a linux environment. 
 I can send commands and receive the proper answer from</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Dec 2016 02:10:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17002/spi-rx-problem" /><item><title>RE: SPI rx problem</title><link>https://devzone.nordicsemi.com/thread/65244?ContentTypeID=1</link><pubDate>Wed, 28 Dec 2016 02:10:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77bd18fc-519f-4f21-ae09-df9c55df7e59</guid><dc:creator>zhouyu</dc:creator><description>&lt;p&gt;I got it. That is because I set #define SPI0_USE_EASY_DMA 1, although I don&amp;#39;t understand why.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI rx problem</title><link>https://devzone.nordicsemi.com/thread/65243?ContentTypeID=1</link><pubDate>Tue, 27 Dec 2016 07:52:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61516825-ae5b-498c-9df8-4c3195c14b75</guid><dc:creator>zhouyu</dc:creator><description>&lt;p&gt;It seems that sdk11 and sdk12 runs in a little bit different way.
Getting flash id in sdk11&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
static uint8_t flash_get_id(uint8_t *manufacturer_id, uint16_t *device_id)
{
  uint8_t tx_buf[5], rx_buf[5];
  tx_buf[0] = W25Q_JEDEC_ID;
  ACCESS_FLASH_DATA(tx_buf, rx_buf, 5); 
  app_trace_log(&amp;quot;[FLASH]%x %x %x %x %x\r\n&amp;quot;, rx_buf[0], rx_buf[1], rx_buf[2],rx_buf[3], rx_buf[4]);
  *manufacturer_id = rx_buf[1];
  *device_id = ((uint16_t)rx_buf[2] &amp;lt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output of rx_buf is &amp;quot;[FLASH]ff ef 40 14 0&amp;quot;&lt;/p&gt;
&lt;p&gt;But in SDK12&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
static uint8_t flash_get_id(uint8_t *manufacturer_id, uint16_t *device_id)
{
  uint8_t tx_buf[5], rx_buf[5];
  tx_buf[0] = W25Q_JEDEC_ID;
  ACCESS_FLASH_DATA(tx_buf, rx_buf, 5); 
  *manufacturer_id = rx_buf[2];
  *device_id = ((uint16_t)rx_buf[3] &amp;lt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The output of rx_buf is &amp;quot;INFO:[FLASH]ff ff ef 40 14&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI rx problem</title><link>https://devzone.nordicsemi.com/thread/65240?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2016 20:31:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8042825b-b730-4afa-a387-5281a4e86bd4</guid><dc:creator>kreis</dc:creator><description>&lt;p&gt;Ok,
thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI rx problem</title><link>https://devzone.nordicsemi.com/thread/65241?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2016 15:25:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d8c7241-d052-4b00-b2e8-cd8b11576b8b</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;That&amp;#39;s the whole point, the RX buffer &lt;em&gt;IS&lt;/em&gt; receiving whilst the bytes are being sent. So you get dummy bytes in the buffer. SPI is a bi-directional protocol, one byte in for every byte out.&lt;/p&gt;
&lt;p&gt;You haven&amp;#39;t checked well enough on the forum, this has been discussed a number of times.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI rx problem</title><link>https://devzone.nordicsemi.com/thread/65242?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2016 14:30:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dfa13dd-e63f-43e2-9c74-10f7e984adbc</guid><dc:creator>kreis</dc:creator><description>&lt;p&gt;Hi RK, thank you very much for answering.
I still think that there&amp;#39;s something strange about it because I had implemented the same memory on another platform (ARM cortex-M3) and I didn&amp;#39;t receive those dummy packages on my rx buffer.
Besides I&amp;#39;ve checked on the forum here for other users examples and from the ones who printed the received buffer I couldn&amp;#39;t find the dummy bytes.
It seems that the rx buffer is also reading while the bytes are being send.&lt;/p&gt;
&lt;p&gt;Thank you for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI rx problem</title><link>https://devzone.nordicsemi.com/thread/65239?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2016 23:45:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a4766fa-3d37-4fee-bd53-04955e4ac42f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;That&amp;#39;s how SPI works, it&amp;#39;s a synchronous read-write protocol, one byte goes out and another byte comes in at the same time. So of course you are going to get extra bytes on the start of the received data because something has to come in whilst the command is going out and only at the next clock can the chip respond with the answer, once it&amp;#39;s seen the command.&lt;/p&gt;
&lt;p&gt;Did you notice that the number of dummy bytes you get at the start of the received message is the same as the number of bytes on the command you clocked out? That should have given you a clue what is going on.&lt;/p&gt;
&lt;p&gt;I suggest you find a description of the SPI protocol online and read it to understand what it&amp;#39;s doing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>