<?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>How to read&amp;amp;Write External Flash with NRF52832  SPI0 ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45597/how-to-read-write-external-flash-with-nrf52832-spi0</link><description>Hi, 
 My problems are as follows: 
 SDK :nRF5_SDK_15.0.0_a53641a. 
 IDE:MDK 5.2.6 
 Chip:nrf52832 SPI0 
 External Flash :W25Q64 
 Now ,I can read the chip ID correctly ,but when I transfer 256 bytes to External Flash ,as if only can write 251 bytes successfully</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Apr 2019 07:47:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45597/how-to-read-write-external-flash-with-nrf52832-spi0" /><item><title>RE: How to read&amp;Write External Flash with NRF52832  SPI0 ?</title><link>https://devzone.nordicsemi.com/thread/179669?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 07:47:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efadfc52-7615-4cf0-ad80-33b0f725b73d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, the EasyDMA in SPIM peripheral support an &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html?cp=2_1_0_30_1#concept_svj_wt2_wr"&gt;ArrayList feature&lt;/a&gt;, allowing you to send multiple buffers after each other.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read&amp;Write External Flash with NRF52832  SPI0 ?</title><link>https://devzone.nordicsemi.com/thread/179626?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 01:54:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03a0805e-1965-4ccd-9460-8a82d7fc0fba</guid><dc:creator>Larkin</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi，thank you for your answer！As it has a limit of 255。may I transmit these 256 bytes twice or more？&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read&amp;Write External Flash with NRF52832  SPI0 ?</title><link>https://devzone.nordicsemi.com/thread/179491?ContentTypeID=1</link><pubDate>Mon, 01 Apr 2019 12:28:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff0cace9-cb9e-4a69-b70c-a8693c32ef91</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The tx_buffer_length and rx_buffer_length parameters in nrf_drv_spi_transfer is declared as uint8_t, meaning it can only hold a length of 255 bytes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t nrf_drv_spi_transfer(nrf_drv_spi_t const * const p_instance,
                                uint8_t const * p_tx_buffer,
                                uint8_t         tx_buffer_length,
                                uint8_t       * p_rx_buffer,
                                uint8_t         rx_buffer_length);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is a limitation of 255 bytes for the MAXCNT registers in SPIM peripherals with EasyDMA support, but legacy SPI peripheral should be able to send longer transfers (1 byte at the time, but the driver will support long transfers).&lt;/p&gt;
&lt;p&gt;If you want to use longer buffers, you can use the &lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-0-0/group__nrfx__spi"&gt;nrfx_spi driver&lt;/a&gt;. Note that the SPIM peripheral is limited to 255 bytes transfers in nRF52832, so you &lt;strong&gt;can not&lt;/strong&gt; use the &lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-0-0/group__nrfx__spim"&gt;nrfx_spim driver&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read&amp;Write External Flash with NRF52832  SPI0 ?</title><link>https://devzone.nordicsemi.com/thread/179406?ContentTypeID=1</link><pubDate>Mon, 01 Apr 2019 08:27:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0265017b-ecb0-46b1-89aa-c4fbf6976b40</guid><dc:creator>Larkin</dc:creator><description>&lt;p&gt;void SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; uint16_t &amp;nbsp;len = NumByteToWrite;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; uint16_t&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt;len_cut = 0; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; uint32_t &amp;nbsp;addr = WriteAddr;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; uint8_t &amp;nbsp; *pic_point_w = pBuffer;&lt;/p&gt;
&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt;SPI_FLASH_WriteEnable();&lt;/p&gt;
&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;Flash_Delsy_ms(500);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; do {&lt;/p&gt;
&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt; &amp;nbsp;memset(FLASH_SPI_Tx_Buf,0x00,255);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FLASH_SPI_Tx_Buf[0] = WRITE;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FLASH_SPI_Tx_Buf[1] = (uint8_t)((addr &amp;amp; 0x00FF0000) &amp;gt;&amp;gt; 16);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FLASH_SPI_Tx_Buf[2] = (uint8_t)((addr &amp;amp; 0x0000FF00) &amp;gt;&amp;gt; 8);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FLASH_SPI_Tx_Buf[3] = (uint8_t) &amp;nbsp;addr ;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; len_cut = (len &amp;gt;= (0xFB - 4)) ? (0xFB) : (len + 4);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; memcpy(&amp;amp;FLASH_SPI_Tx_Buf[4], pic_point_w, (len_cut - 4));&lt;/p&gt;
&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPI_FLASH_CS_LOW;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FLASH_spi_xfer_done = false;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;FLASH_spi, FLASH_SPI_Tx_Buf,len_cut, FLASH_SPI_Rx_Buf, len_cut));&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while(FLASH_spi_xfer_done == false);&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SPI_FLASH_CS_HIGH;&lt;/p&gt;
&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; addr += (len_cut - 4);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pic_point_w += (len_cut - 4);&lt;/p&gt;
&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt; &amp;nbsp;len -= (len_cut - 4);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre;"&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;Flash_Delsy_ms(10);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} while(len &amp;gt; 0);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; SPI_FLASH_CS_HIGH;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; SPI_FLASH_WaitForWriteEnd();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>