<?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 always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83583/spi-slave-always-returns--etimedout</link><description>Hi, I am working on SPI master-slave application, as in, on one BL653 I am running SPI master driver, I am able to observe the waveforms for clock and data transfer from master on USB logic analyzer. But I am facing an issue with the BL653 board which</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 02 Feb 2022 12:45:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83583/spi-slave-always-returns--etimedout" /><item><title>RE: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/350877?ContentTypeID=1</link><pubDate>Wed, 02 Feb 2022 12:45:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6135733-ac12-4b9c-b5d5-3b300e393cb1</guid><dc:creator>Ubaid_M</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/joh2"&gt;J&amp;oslash;rgen Holmefjord&lt;/a&gt;,&lt;br /&gt;&lt;br /&gt;Thank you for the help.&lt;br /&gt;Please mark this thread as closed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/350513?ContentTypeID=1</link><pubDate>Mon, 31 Jan 2022 17:44:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b75cb442-dc2a-4970-af6a-b1f3e1f1bd10</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I would recommend you to have a look at the discussions in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/69034/nrf52840-spi-slave-configuration-event_handler"&gt;this thread&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: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/348831?ContentTypeID=1</link><pubDate>Fri, 21 Jan 2022 06:26:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6194b641-78de-43a4-9899-a3b4ddca3d84</guid><dc:creator>Ubaid_M</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/joh2"&gt;J&amp;oslash;rgen Holmefjord&lt;/a&gt;,&lt;br /&gt;&lt;br /&gt;Thanks, for the suggestion&amp;nbsp;&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/83583/spi-slave-always-returns--etimedout/348452#348452"]Can you try with a different CS pin?[/quote]
&lt;p&gt;After cs configuration, I was facing an issue where&amp;nbsp;&lt;em&gt;&lt;strong&gt;spi_read( )&amp;nbsp;&lt;/strong&gt;&lt;/em&gt;was returning&amp;nbsp; timeout everytime.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With this patch:&lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/39906/commits/dfcc77526163ce6973a5788b202d2a17e4f82d86"&gt;https://github.com/zephyrproject-rtos/zephyr/pull/39906/commits/dfcc77526163ce6973a5788b202d2a17e4f82d86&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I was able to solve this issue, receive &amp;amp; print data on slave board.&lt;br /&gt;&lt;br /&gt;But what i do not understand is I cannot have&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;em&gt;&lt;strong&gt;spi_read( )&lt;/strong&gt;&lt;/em&gt; wait indefinitely, It is a bad application if so,&lt;br /&gt;&lt;br /&gt;Now how can i Optimize this in my application..?&lt;br /&gt;I mean i read data only when it is available &amp;amp; not keep on waiting until data becomes available.&lt;br /&gt;&lt;br /&gt;Kindly suggest&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/joh2"&gt;J&amp;oslash;rgen&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ubaid&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/348452?ContentTypeID=1</link><pubDate>Wed, 19 Jan 2022 10:03:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a1938aa-8007-4850-80bc-47bf7625188b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you try with a different CS pin? P0.01 is by default connected to the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/clock.html#concept_pln_z5y_2q"&gt;32.768 kHz LF crystal&lt;/a&gt; on the &lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf52833_dk/UG/dk/hw_32khz_crystal.html"&gt;nRF52833 DK&lt;/a&gt;.&amp;nbsp;The LF clock is usually started by the RTOS, meaning the pin is already in use and cannot be used with the SPI(S) peripheral.&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: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/347885?ContentTypeID=1</link><pubDate>Sun, 16 Jan 2022 14:49:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78cae5ff-25ff-4529-8a80-94045b80c1b8</guid><dc:creator>Ubaid_M</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt; &amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/joh2"&gt;J&amp;oslash;rgen Holmefjord&lt;/a&gt;&lt;/span&gt;,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Clearly master board it is doing, I think something with slave board or slave pin out config.&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1642267441593v2.png" /&gt;&lt;br /&gt;&lt;br /&gt;Can you have a look at slave code, config and kindlu suggest, as in below.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;SLAVE:************************************&lt;/p&gt;
&lt;p&gt;I am using&amp;nbsp; second board to run as a Slave, an nrf52833_dk,&lt;br /&gt;It&amp;#39;s project is as follows:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;drivers/spi.h&amp;gt;


/*---------------------------------------------------------------------------*/
/*                                                                           */
/*---------------------------------------------------------------------------*/

#define SPI_SLAVE_BUS_NAME     			DT_INST_0_NORDIC_NRF_SPIS_LABEL
#define SPI_SLAVE_GPIOS_NAME    		DT_ALIAS_GPIO_0_LABEL
#define SPI_SLAVE_GPIO_IRQ_PIN  		DT_ALIAS_SPI_0_CSN_PIN

#define STACKSIZE 1024
#define PRIORITY 99

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*---------------------------------------------------------------------------*/
void spi_slave_init(void);

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*---------------------------------------------------------------------------*/
int spi_slave_write(struct device * spi, 
                    struct spi_config * spi_cfg,
                    uint16_t * data)
{
    struct spi_buf bufs = {
            .buf = data,
            .len = 2
    };
    struct spi_buf_set tx = {
        .buffers = &amp;amp;bufs
    };
    
    tx.count = 1;

    return spi_write(spi, spi_cfg, &amp;amp;tx);
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*---------------------------------------------------------------------------*/
int spi_slave_read(struct device * spi, 
                   struct spi_config * spi_cfg,
                   uint16_t * data)
{
    struct spi_buf bufs = {
            .buf = data,
            .len = 2
    };
    struct spi_buf_set rx = {
        .buffers = &amp;amp;bufs
    };
    
    rx.count = 1;

    return spi_read(spi, spi_cfg, &amp;amp;rx);
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*---------------------------------------------------------------------------*/
void spi_slave_init(void)
{
    struct device * spi;
    struct spi_config spi_cfg;

    uint16_t tx_data = 0x5678;
    uint16_t rx_data = 0;

    printk(&amp;quot;SPI Slave example application\n&amp;quot;);

    printk(&amp;quot;rx_data buffer at %p\n&amp;quot;, &amp;amp;rx_data);

    spi = device_get_binding(&amp;quot;SPI_0&amp;quot;);
    if (!spi) {
        printk(&amp;quot;Could not find SPI driver\n&amp;quot;);
        return;
    }

    /*
     *  SPI controller configuration structure for the nRF52 series.
     *
     *  param frequency is the bus frequency in hertz
     *  param operation is a bit field with the following parts:
     *
     *     operational mode  [ 0 ]       - master or slave.
     *     mode              [ 1 : 3 ]   - Polarity, phase and loop mode.
     *     transfer          [ 4 ]       - LSB or MSB first.
     *     word_size         [ 5 : 10 ]  - Size of a data frame in bits.
     *     lines             [ 11 : 12 ] - MISO lines: Single/Dual/Quad/Octal.
     *     cs_hold           [ 13 ]      - Hold on the CS line if possible.
     *     lock_on           [ 14 ]      - Keep resource locked for the caller.
     *     cs_active_high    [ 15 ]      - Active high CS logic.
     *
     *  param slave is the slave number from 0 to host controller slave limit.
     *  param cs is a valid pointer on a struct spi_cs_control is CS line is
     *        emulated through a gpio line, or NULL otherwise.
     */

    /* Note: Implicid Mode-0; e.g. CPOL=0, CPHA=0 -- the only mode supported */
    /* Note: The nRF52 series doesn&amp;#39;t support CS pin configuration */

    memset(&amp;amp;spi_cfg, 0, sizeof(spi_cfg));

    spi_cfg.operation = SPI_WORD_SET(8) | SPI_OP_MODE_SLAVE;
    spi_cfg.frequency = 1000000;
    spi_cfg.slave = 1;

    printk(&amp;quot;%s: slave config @ %p:&amp;quot;
            &amp;quot; wordsize(%u), mode(%u/%u/%u)\n&amp;quot;, __func__, &amp;amp;spi_cfg,
            SPI_WORD_SIZE_GET(spi_cfg.operation),
            (SPI_MODE_GET(spi_cfg.operation) &amp;amp; SPI_MODE_CPOL) ? 1 : 0,
            (SPI_MODE_GET(spi_cfg.operation) &amp;amp; SPI_MODE_CPHA) ? 1 : 0,
            (SPI_MODE_GET(spi_cfg.operation) &amp;amp; SPI_MODE_LOOP) ? 1 : 0);

    while (1) {
        spi_slave_read(spi, &amp;amp;spi_cfg, &amp;amp;rx_data);

        if (rx_data == 0x1234) {
            spi_slave_write(spi, &amp;amp;spi_cfg, &amp;amp;tx_data);
        }
        printk(&amp;quot;Received: 0x%04X -- %s\n&amp;quot;, rx_data,
               (rx_data == 0x1234) ? &amp;quot;ok&amp;quot; : &amp;quot;wrong&amp;quot;); 
    }
}


/*---------------------------------------------------------------------------*/
/*                                                                           */
/*---------------------------------------------------------------------------*/
void spi_slave_thread(void * id, void * unused1, void * unused2)
{
    printk(&amp;quot;%s\n&amp;quot;, __func__);

    spi_slave_init();

    while (1) { /* spin */}
}

K_THREAD_DEFINE(spi_slave_id, STACKSIZE, spi_slave_thread, 
                NULL, NULL, NULL, PRIORITY, 0, 0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;nrf52833dk_nrf52833.overlay:&lt;/p&gt;
&lt;div class="evolution-code-editor theme-clouds"&gt;
&lt;div class=" ace_editor ace-clouds"&gt;
&lt;div class="ace_scroller"&gt;
&lt;div class="ace_content"&gt;
&lt;div class="ace_layer ace_marker-layer"&gt;&lt;/div&gt;
&lt;div class="ace_layer ace_text-layer"&gt;
&lt;div class="ace_line"&gt;/*&lt;/div&gt;
&lt;div class="ace_line"&gt;* Copyright (c) 2019 Callender-Consulting, LLC&lt;/div&gt;
&lt;div class="ace_line"&gt;*&lt;/div&gt;
&lt;div class="ace_line"&gt;* SPDX-License-Identifier: Apache-2.0&lt;/div&gt;
&lt;div class="ace_line"&gt;*/&lt;/div&gt;
&lt;div class="ace_line"&gt;&lt;/div&gt;
&lt;div class="ace_line"&gt;&amp;amp;spi0 {&lt;/div&gt;
&lt;div class="ace_line"&gt;compatible = &amp;quot;nordic,nrf-spis&amp;quot;;&lt;/div&gt;
&lt;div class="ace_line"&gt;status = &amp;quot;okay&amp;quot;;&lt;/div&gt;
&lt;div class="ace_line"&gt;sck-pin = &amp;lt;27&amp;gt;;&lt;/div&gt;
&lt;div class="ace_line"&gt;mosi-pin = &amp;lt;26&amp;gt;;&lt;/div&gt;
&lt;div class="ace_line"&gt;miso-pin = &amp;lt;29&amp;gt;;&lt;/div&gt;
&lt;div class="ace_line"&gt;csn-pin = &amp;lt;1&amp;gt;;&lt;/div&gt;
&lt;div class="ace_line"&gt;def-char = &amp;lt;0xFF&amp;gt;;&lt;/div&gt;
&lt;div class="ace_line"&gt;};&lt;/div&gt;
&lt;/div&gt;
&lt;div class="ace_layer ace_marker-layer"&gt;&lt;/div&gt;
&lt;div class="ace_layer ace_cursor-layer ace_hidden-cursors"&gt;
&lt;div class="ace_cursor"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="content-scrollable-wrapper"&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div class="evolution-code-editor theme-clouds"&gt;&lt;a class="fullscreen" href="https://devzone.nordicsemi.com/f/nordic-q-a/83616/using-spi_write-spi_read-not-behaving-the-same-as-spi_transceive-for-spi-data-in-provided-spi-sample"&gt;&lt;/a&gt;
&lt;div class=" ace_editor ace-clouds"&gt;
&lt;div class="ace_gutter"&gt;
&lt;div class="ace_layer ace_gutter-layer ace_folding-enabled"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="ace_scroller"&gt;
&lt;div class="ace_content"&gt;
&lt;div class="ace_layer ace_print-margin-layer"&gt;
&lt;div class="ace_print-margin"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="ace_layer ace_marker-layer"&gt;&lt;/div&gt;
&lt;div class="ace_layer ace_text-layer"&gt;
&lt;div class="ace_line"&gt;# nothing here&lt;/div&gt;
&lt;div class="ace_line"&gt;CONFIG_DEBUG=y&lt;/div&gt;
&lt;div class="ace_line"&gt;&lt;/div&gt;
&lt;div class="ace_line"&gt;CONFIG_GPIO=y&lt;/div&gt;
&lt;div class="ace_line"&gt;&lt;/div&gt;
&lt;div class="ace_line"&gt;CONFIG_SPI=y&lt;/div&gt;
&lt;div class="ace_line"&gt;CONFIG_SPI_SLAVE=y&lt;/div&gt;
&lt;div class="ace_line"&gt;CONFIG_PRINTK=y&lt;/div&gt;
&lt;/div&gt;
&lt;div class="ace_layer ace_marker-layer"&gt;&lt;/div&gt;
&lt;div class="ace_layer ace_cursor-layer ace_hidden-cursors"&gt;
&lt;div class="ace_cursor"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Hardware connections:&lt;/p&gt;
&lt;p&gt;SCLK : M-41 : S-27&lt;br /&gt;MOSI : M-40 : S-26&lt;/p&gt;
&lt;p&gt;MISO : M-04 : S-29&lt;/p&gt;
&lt;p&gt;CS :&amp;nbsp; &amp;nbsp; &amp;nbsp;M-23 : S-1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Kindly suggest where i can look for further, I have evaluated everything yet to no avail&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/347872?ContentTypeID=1</link><pubDate>Sat, 15 Jan 2022 17:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4847bb62-98a1-4133-aaac-1b413b1ac0b5</guid><dc:creator>Ubaid_M</dc:creator><description>&lt;p&gt;Hello&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/joh2"&gt;J&amp;oslash;rgen Holmefjord&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/83583/spi-slave-always-returns--etimedout/347626#347626"]Are the CSN pin connected and toggling as expected?[/quote]
&lt;p&gt;&lt;br /&gt;I have uploaded the code and csn pin states on a logic analyser in the case:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/83616/using-spi_write-spi_read-not-behaving-the-same-as-spi_transceive-for-spi-data-in-provided-spi-sample"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/83616/using-spi_write-spi_read-not-behaving-the-same-as-spi_transceive-for-spi-data-in-provided-spi-sample&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Same problem yet,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I have tried everything, yet no progress, can you kindly help out on why I am unable to receive data on slave board.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Ubaid&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/347639?ContentTypeID=1</link><pubDate>Thu, 13 Jan 2022 15:27:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d05dbbb3-c449-4129-8cb0-18a92d1e929e</guid><dc:creator>Ubaid_M</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt;J&amp;oslash;rgen,&lt;br /&gt;&lt;br /&gt;Thank you so much, Master&amp;#39;s signals I am able to observe on USB logic analyzer, CLK, MOSI &amp;amp; CS (all three),&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;as in below snap, cs stays low for 26micro secs during which master board is sending data:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1642087538045v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;Roughly below is my slave code&amp;nbsp;J&amp;oslash;rgen, running on another board:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;
#define SPI_DEVICE_NAME_P1 DT_LABEL(DT_NODELABEL(spi1))
const device *m_spi_dev;
struct spi_config *m_spi_cfg = new spi_config();
void main(void)
{

	uint8_t spi_channel = 1;
	bool is_master;

	uint8_t port = 0;
	uint8_t pin = 23;
	uint32_t flag = GPIO_ACTIVE_LOW;//GPIO_OUTPUT_ACTIVE;
	
    m_spi_dev = device_get_binding(SPI_DEVICE_NAME_P1);
    
    m_spi_cfg-&amp;gt;frequency =  4000000;
    m_spi_cfg-&amp;gt;operation |= SPI_OP_MODE_SLAVE;
    m_spi_cfg-&amp;gt;slave = 1;
    m_spi_cfg-&amp;gt;operation |= SPI_WORD_SET(8);
    
    const struct device	*gpio_dev = device_get_binding(&amp;quot;GPIO_0&amp;quot;);
    uint8_t gpio_pin_t = 23;
    uint8_t gpio_dt_flags_t = GPIO_ACTIVE_LOW;
    
    gpio_pin_configure(gpio_dev, gpio_pin_t, GPIO_INPUT | gpio_dt_flags_t);
    
    static uint8_t rx_buffer[1];
    struct spi_buf rx_buf = {
.buf = rx_buffer,
.len = sizeof(rx_buffer),
};	

const struct spi_buf_set rx = {
.buffers = &amp;amp;rx_buf,
.count = 1
};
    
    while(true)
    {
    	l_nStatus = spi_read(m_spi_dev, m_spi_cfg, &amp;amp;rx);
		printk(&amp;quot;RX recv: %u : %d \n&amp;quot;, rx_buffer[0],l_nStatus);
		if (l_nStatus != SUCCESS)
		{
			return ERR;
		}
        
    }
    
    }
    
    &lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;prj.conf:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#C++ support configs
CONFIG_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC=y
CONFIG_LIB_CPLUSPLUS=y
CONFIG_HEAP_MEM_POOL_SIZE=16348
CONFIG_OPENOCD_SUPPORT=n

#SPI
CONFIG_SPI=y
CONFIG_SPI_SLAVE=y
CONFIG_LOG=y
#CONFIG_SPI_ASYNC=y&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;overlay:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spis&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	sck-pin = &amp;lt;41&amp;gt;;
	mosi-pin = &amp;lt;40&amp;gt;;
	miso-pin = &amp;lt;4&amp;gt;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 23 0&amp;gt;;
	csn-pin = &amp;lt;23&amp;gt;;
    def-char = &amp;lt;0xFF&amp;gt;;
};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now with this code&amp;nbsp;I am getting prints for:&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;-ETIMEDOUT&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;span&gt;or&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-&lt;/span&gt;EIO&lt;/p&gt;
&lt;p&gt;Being generated from adc_context.h&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/347626?ContentTypeID=1</link><pubDate>Thu, 13 Jan 2022 14:39:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61f35eb4-569d-4f07-8f1a-d79f82bf0c50</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you share the rest of the source code, and your prj.conf file?&lt;/p&gt;
&lt;p&gt;Where are you calling the&amp;nbsp;&lt;span&gt;spi_read() function?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Are the CSN pin connected and toggling as expected?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI slave always returns -ETIMEDOUT</title><link>https://devzone.nordicsemi.com/thread/347487?ContentTypeID=1</link><pubDate>Thu, 13 Jan 2022 05:55:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73b31ec9-f122-4066-9e4f-38df8c52b89c</guid><dc:creator>Ubaid_M</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Also adding my overlay file details for your reference:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spis&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	sck-pin = &amp;lt;41&amp;gt;;
	mosi-pin = &amp;lt;40&amp;gt;;
	miso-pin = &amp;lt;4&amp;gt;;
	cs-gpios = &amp;lt;&amp;amp;gpio1 23 0&amp;gt;;
	csn-pin = &amp;lt;23&amp;gt;;
	def-char = &amp;lt;0xFF&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kindly suggest,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>