<?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>SPIS set buffer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39387/spis-set-buffer</link><description>Hi, 
 I have a doubt regarding buffer setting in SPIS. 
 In the SDK15 SPIS example, buffers are set using nrfx_spis_buffers_set(...) and it works perfectly. 
 I was wondering if it&amp;#39;s possible to avoid the buffer_set cal, setting a fixed RAM region using</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Oct 2018 10:14:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39387/spis-set-buffer" /><item><title>RE: SPIS set buffer</title><link>https://devzone.nordicsemi.com/thread/152659?ContentTypeID=1</link><pubDate>Fri, 12 Oct 2018 10:14:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e71155c-d2d1-4eb1-9555-253a0c507dc6</guid><dc:creator>MarcoR</dc:creator><description>&lt;p&gt;I am connecting 2 nrf52832 boards. The SPI master works with the &amp;quot;spi&amp;quot;&amp;nbsp;SDK example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIS set buffer</title><link>https://devzone.nordicsemi.com/thread/152658?ContentTypeID=1</link><pubDate>Fri, 12 Oct 2018 10:06:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:195224b3-97de-48fe-b05b-eff349a9fce6</guid><dc:creator>MarcoR</dc:creator><description>&lt;p&gt;Thank you&lt;span&gt;&amp;nbsp;&lt;/span&gt;haakonsh&lt;span&gt;&amp;nbsp;&lt;/span&gt;for your reply.&lt;/p&gt;
&lt;p&gt;Starting from the SDK example I deleted the nrf_drv_spis_buffers_set row in while(1) and I made these attempts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I set the buffers after the initialization:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    NRF_LOG_INFO(&amp;quot;SPIS example&amp;quot;);

    nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG;
    spis_config.csn_pin               = APP_SPIS_CS_PIN;
    spis_config.miso_pin              = APP_SPIS_MISO_PIN;
    spis_config.mosi_pin              = APP_SPIS_MOSI_PIN;
    spis_config.sck_pin               = APP_SPIS_SCK_PIN;

    APP_ERROR_CHECK(nrf_drv_spis_init(&amp;amp;spis, &amp;amp;spis_config, spis_event_handler));
	  nrf_drv_spis_buffers_set(&amp;amp;spis, m_tx_buf, m_length, m_rx_buf, m_length);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In this way the SPIS sends correctly only during the fist HITOLO transition of master chip select, then the MISO becomes HIGH and doesn&amp;#39;t trasmit data anymore.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I set the buffers also in the&amp;nbsp;spis_event_handler, like in the code below reported:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void spis_event_handler(nrf_drv_spis_event_t event)
{
    if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
    {
        spis_xfer_done = true;
        NRF_LOG_INFO(&amp;quot; Transfer completed. Received: %s&amp;quot;,(uint32_t)m_rx_buf);
				nrf_drv_spis_buffers_set(&amp;amp;spis, m_tx_buf, m_length, m_rx_buf, m_length);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In this way the SPIS works fine but I have to recall&amp;nbsp;nrf_drv_spis_buffers_set for every transition.&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t change anything also from the example code, I report it for completeness:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 * 
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 * 
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 * 
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 * 
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */
#include &amp;quot;sdk_config.h&amp;quot;
#include &amp;quot;nrf_drv_spis.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;lt;string.h&amp;gt;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

#define SPIS_INSTANCE 1 /**&amp;lt; SPIS instance index. */
static const nrf_drv_spis_t spis = NRF_DRV_SPIS_INSTANCE(SPIS_INSTANCE);/**&amp;lt; SPIS instance. */

#define TEST_STRING &amp;quot;Nordic&amp;quot;
static uint8_t       m_tx_buf[] = TEST_STRING;           /**&amp;lt; TX buffer. */
static uint8_t       m_rx_buf[sizeof(TEST_STRING) + 1];    /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**&amp;lt; Transfer length. */

static volatile bool spis_xfer_done; /**&amp;lt; Flag used to indicate that SPIS instance completed the transfer. */

/**
 * @brief SPIS user event handler.
 *
 * @param event
 */
void spis_event_handler(nrf_drv_spis_event_t event)
{
    if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
    {
        spis_xfer_done = true;
        NRF_LOG_INFO(&amp;quot; Transfer completed. Received: %s&amp;quot;,(uint32_t)m_rx_buf);
				nrf_drv_spis_buffers_set(&amp;amp;spis, m_tx_buf, m_length, m_rx_buf, m_length);
    }
}

int main(void)
{
    // Enable the constant latency sub power mode to minimize the time it takes
    // for the SPIS peripheral to become active after the CSN line is asserted
    // (when the CPU is in sleep mode).
    NRF_POWER-&amp;gt;TASKS_CONSTLAT = 1;

    bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO(&amp;quot;SPIS example&amp;quot;);

    nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG;
    spis_config.csn_pin               = APP_SPIS_CS_PIN;
    spis_config.miso_pin              = APP_SPIS_MISO_PIN;
    spis_config.mosi_pin              = APP_SPIS_MOSI_PIN;
    spis_config.sck_pin               = APP_SPIS_SCK_PIN;

    APP_ERROR_CHECK(nrf_drv_spis_init(&amp;amp;spis, &amp;amp;spis_config, spis_event_handler));
	  nrf_drv_spis_buffers_set(&amp;amp;spis, m_tx_buf, m_length, m_rx_buf, m_length);
	  

    while (1)
    {
        memset(m_rx_buf, 0, m_length);
        spis_xfer_done = false;

//        APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&amp;amp;spis, m_tx_buf, m_length, m_rx_buf, m_length));

        while (!spis_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();

        bsp_board_led_invert(BSP_BOARD_LED_0);
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Did I make any&amp;nbsp;mistake during the initialization?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIS set buffer</title><link>https://devzone.nordicsemi.com/thread/152580?ContentTypeID=1</link><pubDate>Fri, 12 Oct 2018 06:28:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ee7e25d-4462-425f-be8e-58fa9d65601b</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;If you want to re-use your tx/rx buffers then you only need to call&amp;nbsp;&lt;span&gt;nrfx_spis_buffers_set once during initialization. The SPIS will use whatever&amp;#39;s in the RXD/TXD registers and it does not reset the register after a transaction is completed.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIS set buffer</title><link>https://devzone.nordicsemi.com/thread/152579?ContentTypeID=1</link><pubDate>Fri, 12 Oct 2018 06:27:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:699eee6d-a553-4506-9e1a-7d60eaadcf18</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;If you want to re-use your tx/rx buffers then you only need to call&amp;nbsp;&lt;span&gt;nrfx_spis_buffers_set once during initialization. The SPIS will use whatever&amp;#39;s in the RXD/TXD registers and it does not reset the register after a transaction is completed.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>