<?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>Issues with SPI and nrf52dk</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/127113/issues-with-spi-and-nrf52dk</link><description>Hello Nordic Forums. 
 I have been struggling for the past couple of days to try to get the SPI working. I never thought that something this easy could have become such a nightmare. I tried compiling and running sample test from Lesson 5 of the Intermediate</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Mar 2026 12:18:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/127113/issues-with-spi-and-nrf52dk" /><item><title>RE: Issues with SPI and nrf52dk</title><link>https://devzone.nordicsemi.com/thread/562423?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2026 12:18:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e32a0e39-4ddc-4d55-9d1c-d80038b5c6ee</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am very glad that you have solved the issue and thank you so much to share this with other users.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Kazi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with SPI and nrf52dk</title><link>https://devzone.nordicsemi.com/thread/562245?ContentTypeID=1</link><pubDate>Fri, 27 Feb 2026 17:11:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1bf4c0a-6c6f-45b0-8c03-9ad3c0afb613</guid><dc:creator>federicoc</dc:creator><description>&lt;p&gt;Thank you, Kazi, for guiding me in the right direction. I&amp;#39;ve uploaded a complete working solution to this GitHub repository, hoping it will assist others facing the same issue: &lt;br /&gt;&lt;a title="SPI configuration on nrf52" href="https://github.com/f-calzi/nrf52-zephyr-rtos-spi"&gt;nrf52-zephyr-rtos-spi&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;After setting up CS within the SPI node configuration, I successfully established communication. No need to manually control CS. The key was to configure the SPI in the overlay file in this manner:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;spi1_default&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
    cs-gpios = &amp;lt;&amp;amp;gpio0 11 GPIO_ACTIVE_LOW&amp;gt;;
    spi_node: spi-dev-a@0 {
		reg = &amp;lt;0&amp;gt;;
	};
};&lt;/pre&gt;&lt;br /&gt;Thank you again and have a great weekend.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with SPI and nrf52dk</title><link>https://devzone.nordicsemi.com/thread/562142?ContentTypeID=1</link><pubDate>Thu, 26 Feb 2026 12:44:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99c44955-d577-40d6-9032-3585c8036aa4</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;CS pin is part of any SPI node as child node so zephyr will not associate any CS with that bus. There is previous case &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/109261/the-cs-pin-of-the-spi-is-not-working"&gt;(+) The cs pin of the spi is not working - Nordic Q&amp;amp;A - Nordic DevZone - Nordic DevZone&lt;/a&gt;&amp;nbsp;you can look at.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with SPI and nrf52dk</title><link>https://devzone.nordicsemi.com/thread/561885?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 17:39:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d06a75b-46a6-4b0a-8c1c-98a3b5e1430a</guid><dc:creator>federicoc</dc:creator><description>&lt;p&gt;Thank you Kazi for your reply.&lt;/p&gt;
&lt;p&gt;My understanding is that if a pin is Active Low, then passing 0U to&amp;nbsp;gpio_pin_set_dt(&amp;amp;cs, 0U) means that we intend to set the pin to its Inactive state, which is High.&lt;br /&gt;I confirmed this behavior with leds and so on, and clearly the trace from the logic analyzer shows that I am pulling the cs line low when transmitting data with the following code. And I&amp;#39;ve confirmed that If set &amp;amp;cs to 0U, then call tranceive and the set cs to 1U, I will not get any data transmission.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1771867322440v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;gpio_pin_set_dt(&amp;amp;cs, 1U);
err = spi_transceive(spi1_dev, &amp;amp;spi_cfg,
                 &amp;amp;spi_tx_buf_set, &amp;amp;spi_rx_buf_set);
gpio_pin_set_dt(&amp;amp;cs, 0U);&lt;/pre&gt;&lt;br /&gt;Now, I&amp;#39;ve updated the code as follows:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;
#include &amp;lt;zephyr/drivers/spi.h&amp;gt;
#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/devicetree.h&amp;gt;
#define SLEEP_TIME_MS   5000
#define LED0_NODE DT_ALIAS(led0)
#define SPI1_NODE DT_NODELABEL(spi1)
static const struct device *spi1_dev = DEVICE_DT_GET(SPI1_NODE);
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
static const struct gpio_dt_spec cs = GPIO_DT_SPEC_GET_OR(DT_NODELABEL(cs_one_pin), gpios, {0});
static struct spi_config spi_cfg = {
	.frequency = 1000000U,
	.operation = SPI_WORD_SET(8),
	.slave = 0
};
static void readRegister(uint8_t reg, uint8_t values[], uint8_t size)
{
	int err; 
	uint8_t tx_buffer[3];
	tx_buffer[0] = 0x80; // read operation
	tx_buffer[1] = reg;  // registry
	tx_buffer[2] = 0x00; // dummy byte for result

	struct spi_buf tx_spi_bufs[] = {
		{.buf = tx_buffer, .len = sizeof(tx_buffer)}
	};
	struct spi_buf_set spi_tx_buf_set = {
		.buffers = tx_spi_bufs, 
		.count = 1
	};
	struct spi_buf rx_spi_bufs[] = {
		{.buf = values, .len = size}
	};
	struct spi_buf_set spi_rx_buf_set = {
		.buffers = rx_spi_bufs, 
		.count = 1
	};

	gpio_pin_set_dt(&amp;amp;cs, 1U);
	err = spi_transceive(spi1_dev, &amp;amp;spi_cfg,
                     &amp;amp;spi_tx_buf_set, &amp;amp;spi_rx_buf_set);
	gpio_pin_set_dt(&amp;amp;cs, 0U);
	if(err &amp;gt; 0)
	{
		printf(&amp;quot;Error when sending spi message!&amp;quot;);
	}   
}
static void readChipID(void) {
	uint8_t rx_buf_chipid[4];
	readRegister(0x00, rx_buf_chipid, 3);
	printf(&amp;quot;Received: %X, %X, %X\n&amp;quot;, rx_buf_chipid[0], rx_buf_chipid[1], rx_buf_chipid[2]);
}
int main(void)
{
	int ret;
	bool led_state = true;
	if (!gpio_is_ready_dt(&amp;amp;led)) {
		return 0;
	}
	if(!device_is_ready(spi1_dev)) {
		return 0;
	}
	ret = gpio_pin_configure_dt(&amp;amp;led, GPIO_OUTPUT_ACTIVE);
	if (ret &amp;lt; 0) {
		return 0;
	}
	ret = gpio_pin_configure_dt(&amp;amp;cs, GPIO_OUTPUT);
	if (ret &amp;lt; 0) {
		return 0;
	}
	printf(&amp;quot;Setup completed!&amp;quot;);

	while (1) {
		ret = gpio_pin_toggle_dt(&amp;amp;led);
		if (ret &amp;lt; 0) {
			return 0;
		}
		readChipID();
		k_msleep(SLEEP_TIME_MS);
	}
	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;and the overlay file as:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;
/ {
    cs_one_pin: cs-one-pin {
                compatible = &amp;quot;nordic,gpio-pins&amp;quot;;
                gpios = &amp;lt;&amp;amp;gpio0 11 GPIO_ACTIVE_LOW&amp;gt;;
                status = &amp;quot;okay&amp;quot;;
    };
};

&amp;amp;spi1 {
	compatible = &amp;quot;nordic,nrf-spi&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;spi1_default&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

&amp;amp;pinctrl {
    spi1_default: spi1_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 31)&amp;gt;,
                    &amp;lt;NRF_PSEL(SPIM_MOSI, 0, 30)&amp;gt;,
                    &amp;lt;NRF_PSEL(SPIM_MISO, 0, 29)&amp;gt;;
        };
    };

    spi1_sleep: spi1_sleep {
        group1 {
            psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 31)&amp;gt;,
                    &amp;lt;NRF_PSEL(SPIM_MOSI, 0, 30)&amp;gt;,
                    &amp;lt;NRF_PSEL(SPIM_MISO, 0, 29)&amp;gt;;
            low-power-enable;
        };
    };
};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;However on nrf52dk I am receiving back the following values from the transmission:&lt;br /&gt;FF F&lt;strong&gt;F 40&lt;/strong&gt;&lt;br /&gt;While the logic analyzer shows&lt;br /&gt;FF F&lt;strong&gt;E 60&lt;br /&gt;&lt;/strong&gt;I am wondering what is causing this discrepancy as the correct registry value for the BMP390 is &lt;strong&gt;0x60&lt;/strong&gt;.&lt;br /&gt;I have confirmed that I am able to get the correct registry value from the sensor using arduino library.&lt;br /&gt;Could be this due to the following errata?&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1771868350337v2.png" alt=" " /&gt;&lt;br /&gt;&lt;a id="" href="https://docs.nordicsemi.com/bundle/errata_nRF52840_EngA/page/ERR/nRF52840/EngineeringA/latest/anomaly_840_58.html"&gt;https://docs.nordicsemi.com/bundle/errata_nRF52840_EngA/page/ERR/nRF52840/EngineeringA/latest/anomaly_840_58.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Moreover I noticed that in the example from Nordic Academy, there is no need to pull cs manually with the transceive command. Do I need to do so?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Do i need to add a node to the SPI (if so which node should I add, since I could not find a bmp390 in the library)?&lt;br /&gt;&lt;br /&gt;Thank you again.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with SPI and nrf52dk</title><link>https://devzone.nordicsemi.com/thread/561797?ContentTypeID=1</link><pubDate>Mon, 23 Feb 2026 09:20:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d942b41-b750-42f3-804d-306d47689b81</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I can see in the overlay you have set CS pin active low. That means CS is high before the transfer (inactive state), CS is inactive while doing write+read operation. After the transfer CS will be pulled low.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
 cs_one_pin: cs-one-pin {
 compatible = &amp;quot;nordic,gpio-pins&amp;quot;;
 gpios = &amp;lt;&amp;amp;gpio0 11 GPIO_ACTIVE_LOW&amp;gt;;
 status = &amp;quot;okay&amp;quot;;
 };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But in the code, you set reverse.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; gpio_pin_set_dt(&amp;amp;cs, 1U);
 
 do {
    err = spi_write(spi1_dev, &amp;amp;spi_cfg, &amp;amp;spi_tx_buf_set);
    if(err &amp;lt; 0)
    {
     break;
    }
     err = spi_read(spi1_dev, &amp;amp;spi_cfg, &amp;amp;spi_rx_buf_set);
    }
    while(false);
    gpio_pin_set_dt(&amp;amp;cs, 0U); 
  }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can try to fix this by asserting CS low before transfer the data and de-assert high after the transmission.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;gpio_pin_set_dt(&amp;amp;cs, 0U);   // CS active (low)

err = spi_transceive(spi1_dev, &amp;amp;spi_cfg,
                     &amp;amp;spi_tx_buf_set, &amp;amp;spi_rx_buf_set);// instead of spi_read you can use spi_transcive()

gpio_pin_set_dt(&amp;amp;cs, 1U);   // CS inactive (high)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In device tree overlay you have not binded&amp;nbsp;&lt;code dir="ltr"&gt;spi1_default&lt;/code&gt;&lt;span&gt;&amp;nbsp;to&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;spi1.&amp;nbsp;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Try to change the device-tree following way:&lt;code dir="ltr"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {
    spi1_default: spi1_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 31)&amp;gt;,
                    &amp;lt;NRF_PSEL(SPIM_MOSI, 0, 30)&amp;gt;,
                    &amp;lt;NRF_PSEL(SPIM_MISO, 0, 29)&amp;gt;;
        };
    };

    spi1_sleep: spi1_sleep {
        group1 {
            psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 31)&amp;gt;,
                    &amp;lt;NRF_PSEL(SPIM_MOSI, 0, 30)&amp;gt;,
                    &amp;lt;NRF_PSEL(SPIM_MISO, 0, 29)&amp;gt;;
            low-power-enable;
        };
    };
};

&amp;amp;gpio0 {
    status = &amp;quot;okay&amp;quot;;
};

&amp;amp;gpiote0 {
    status = &amp;quot;okay&amp;quot;;
};

&amp;amp;spi1 {
    compatible = &amp;quot;nordic,nrf-spi&amp;quot;;
    status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;spi1_default&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};

/ {
    cs_one_pin: cs-one-pin {
        compatible = &amp;quot;nordic,gpio-pins&amp;quot;;
        gpios = &amp;lt;&amp;amp;gpio0 11 GPIO_ACTIVE_LOW&amp;gt;;
        status = &amp;quot;okay&amp;quot;;
    };
};&lt;/pre&gt;&lt;code dir="ltr"&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>