<?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 interface problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52370/spi-interface-problem</link><description>Hi, 
 I am using customized nrf52 board with softdevice s132 
 I am trying to interface External Flash (MX25L64) using spi.so when ever i am trying to send any command /data to external flash i am getting only zero in the receiving buffer or else other</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Sep 2019 07:51:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52370/spi-interface-problem" /><item><title>RE: Spi interface problem</title><link>https://devzone.nordicsemi.com/thread/211124?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 07:51:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:790447b9-5c3e-4334-8417-069c71bdfb1b</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Did you implement the bug fixes &lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt; suggested? Have you remembered to set the correct frequency, etc. according to the &lt;span&gt;MX25L64?&amp;nbsp;&lt;/span&gt;Do you have a logic analyzer available so you can check that you&amp;#39;re sending the correct info to the external memory?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spi interface problem</title><link>https://devzone.nordicsemi.com/thread/210844?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2019 07:45:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87ba2e96-c1c4-4dce-9480-b23b7fc68263</guid><dc:creator>SAIF</dc:creator><description>&lt;p&gt;Hi,i have tried what u said ,but still i got the same problem.&lt;/p&gt;
&lt;p&gt;i have commented&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FLASH_IO_CS_High();&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FLASH_IO_CS_low();&lt;/p&gt;
&lt;p&gt;and checked it&lt;/p&gt;
&lt;p&gt;i will send the log&amp;nbsp; statements&lt;pre class="ui-code" data-mode="text"&gt;Spi...Init....

SPI example started.  = 0 

Byte = 159 and SPI_WRITE_READ  = 0 == 194 === 0 ==== 0 err_code = 0

Byte = 0 and SPI_WRITE_READ  = 0 == 0 === 0 ==== 0 err_code = 0

Byte = 0 and SPI_WRITE_READ  = 0 == 0 === 0 ==== 0 err_code = 0

Byte = 0 and SPI_WRITE_READ  = 0 == 0 === 0 ==== 0 err_code = 0
Temp = 0 Temp0 = 0 Temp1 =0 Temp2 = 0
Id = 0 

byte write done beginning 

Byte = 6 and SPI_WRITE_READ  = 0 == 0 === 3 ==== 0 err_code = 0

Byte = 2 and SPI_WRITE_READ  = 0 == 0 === 3 ==== 0 err_code = 0

Byte = 0 and SPI_WRITE_READ  = 0 == 0 === 3 ==== 0 err_code = 0

Byte = 0 and SPI_WRITE_READ  = 0 == 0 === 3 ==== 0 err_code = 0

Byte = 1 and SPI_WRITE_READ  = 0 == 0 === 3 ==== 0 err_code = 0

Byte = 5 and SPI_WRITE_READ  = 0 == 0 === 3 ==== 0 err_code = 0

byte write done end

Byte = 3 and SPI_WRITE_READ  = 0 == 0 === 0 ==== 0 err_code = 0

Byte = 0 and SPI_WRITE_READ  = 0 == 0 === 0 ==== 0 err_code = 0

Byte = 0 and SPI_WRITE_READ  = 0 == 0 === 0 ==== 0 err_code = 0

Byte = 1 and SPI_WRITE_READ  = 0 == 0 === 0 ==== 0 err_code = 0

 0 4 0 32
Mx25L64_BYTE_Read = 0 

/*here i am getting some different values in the receiving  buffer while reading*/&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Spi interface problem</title><link>https://devzone.nordicsemi.com/thread/210793?ContentTypeID=1</link><pubDate>Thu, 19 Sep 2019 22:09:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41f073fe-a855-4b6e-b31f-d3a33fa2c210</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Manually controlling the CS pin requires that you change .ss_pin to stop the Nordic library code also controlling the pin from this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;spi_config.ss_pin   = SPI_SS_PIN;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;spi_config.ss_pin = NRF_DRV_SPI_PIN_NOT_USED;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is also a bug here, as if more than 1 byte is transmitted a pointer to an array of bytes must be used, not the address of a single byte&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;Byte, 2, pData, 2);
// if only 1 byte change to this:
err_code = nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;Byte, 1, pData, 2);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Same problem here and in other places, &lt;em&gt;spi_transfer&lt;/em&gt; requires a pointer to an array or the address of a byte if only sending 1 byte&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t* FLASH_IO_WriteReadByte(uint8_t data,uint8_t len)
{
    ret_code_t err_code;
    err_code = nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;data, len, Rxbuff, len);
    APP_ERROR_CHECK(err_code);
	  return Rxbuff;
}

change to something like this:

uint8_t* FLASH_IO_WriteReadByte(uint8_t * p_data,uint8_t len)
{
    ret_code_t err_code;
    err_code = nrf_drv_spi_transfer(&amp;amp;spi, p_data, len, Rxbuff, len);
    APP_ERROR_CHECK(err_code);
	  return Rxbuff;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s all I can help with, too busy fixing my own projects ..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>