<?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>problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42736/problems-with-spi-on-nrf9160-and-zephyr</link><description>I am trying to develop a SPI interface to a CANBUS controller for the nRF9160 for the zephyr platform. 
 The issue I am having at this point is is that I am unable to see any activity on the SPI lines from the nRF9160. 
 My first test of the SPI is to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 23 May 2019 18:58:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42736/problems-with-spi-on-nrf9160-and-zephyr" /><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/188918?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 18:58:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:868e9624-c0f0-4b34-b7ae-fe6542b8312c</guid><dc:creator>RodWatt</dc:creator><description>&lt;p&gt;Thanks Jeff&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/182926?ContentTypeID=1</link><pubDate>Mon, 22 Apr 2019 11:33:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13a2c661-22e5-4ebd-83e9-732d013b868d</guid><dc:creator>Jeff Seaman</dc:creator><description>&lt;p&gt;I have not worked with this in some time.&amp;nbsp; I was running the loopback test.&lt;/p&gt;
&lt;p&gt;check the configuration of secure boot and also I have had to add some peripherals in the secure boot source code to enable them so make sure the spi is set in that and the secure boot prj.conf files matches what you are using in the program prj.conf file.&lt;/p&gt;
&lt;p&gt;also print out the device value once you have configured it and make sure it is not 0.&amp;nbsp; a zero value shows the peripheral is not avilable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/182841?ContentTypeID=1</link><pubDate>Fri, 19 Apr 2019 21:57:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:815ba931-4c3c-4682-a59f-21f7f3a32ce8</guid><dc:creator>RodWatt</dc:creator><description>&lt;p&gt;Hi Jeff,&lt;/p&gt;
&lt;p&gt;Did you manage to get this working? I am also trying to get the SPI interface up and running. I can run the basic SPI loopback test but am unable to get access to and SPI peripheral. I am trying to get the the BME280 code working, works with I2C but I can&amp;#39;t get it to work with SPI. Anyway, any tips you can share would be appreciated. Thanks, Rod&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/169037?ContentTypeID=1</link><pubDate>Fri, 01 Feb 2019 11:29:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5adee24a-41fb-4d86-bb52-bbe6f09183a9</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;There&amp;#39;s a very simplistic SPI3 example&amp;nbsp;linked in this case, if anyone is interested:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/43185/unable-to-modify-nrf9160dk-asset_tracker-to-add-spi-slave-functionality/169035#169035"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/43185/unable-to-modify-nrf9160dk-asset_tracker-to-add-spi-slave-functionality/169035#169035&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;H&amp;aring;kon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/167909?ContentTypeID=1</link><pubDate>Fri, 25 Jan 2019 12:42:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7de9838c-b16e-491c-98e2-0989ca76752f</guid><dc:creator>Jeff Seaman</dc:creator><description>&lt;p&gt;Hi Jan&lt;/p&gt;
&lt;p&gt;I just took one of the Zephyr samples and started to adapt to see how things work.&amp;nbsp; Once I got some activity my plan was to make it work with my chip.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;misc/printk.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;spi.h&amp;gt;

/**
 * @file Sample app using the Fujitsu MB85RS64V FRAM through SPI.
 */

#define MB85RS64V_MANUFACTURER_ID_CMD 0x9f
#define MB85RS64V_WRITE_ENABLE_CMD 0x06
#define MB85RS64V_READ_CMD 0x03
#define MB85RS64V_WRITE_CMD 0x02
#define MAX_USER_DATA_LENGTH 1024

static u8_t data[MAX_USER_DATA_LENGTH], cmp_data[MAX_USER_DATA_LENGTH];

static int mb85rs64v_access(struct device *spi, struct spi_config *spi_cfg,
			    u8_t cmd, u16_t addr, void *data, size_t len)
{
	u8_t access[3];
	struct spi_buf bufs[] = {
		{
			.buf = access,
		},
		{
			.buf = data,
			.len = len
		}
	};
	struct spi_buf_set tx = {
		.buffers = bufs
	};

	access[0] = cmd;

	if (cmd == MB85RS64V_WRITE_CMD || cmd == MB85RS64V_READ_CMD) {
		access[1] = (addr &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;
		access[2] = addr &amp;amp; 0xFF;

		bufs[0].len = 3;
		tx.count = 2;

		if (cmd == MB85RS64V_READ_CMD) {
			struct spi_buf_set rx = {
				.buffers = bufs,
				.count = 2
			};

			return spi_transceive(spi, spi_cfg, &amp;amp;tx, &amp;amp;rx);
		}
	} else {
		tx.count = 1;
	}

	return spi_write(spi, spi_cfg, &amp;amp;tx);
}


static int mb85rs64v_read_id(struct device *spi, struct spi_config *spi_cfg)
{
	u8_t id[4];
	int err;

	err = mb85rs64v_access(spi, spi_cfg,
			       MB85RS64V_MANUFACTURER_ID_CMD, 0, &amp;amp;id, 4);
	if (err) {
		printk(&amp;quot;Error during ID read\n&amp;quot;);
		return -EIO;
	}

	if (id[0] != 0x04) {
		return -EIO;
	}

	if (id[1] != 0x7f) {
		return -EIO;
	}

	if (id[2] != 0x03) {
		return -EIO;
	}

	if (id[3] != 0x02) {
		return -EIO;
	}

	return 0;
}

static int write_bytes(struct device *spi, struct spi_config *spi_cfg,
		       u16_t addr, u8_t *data, u32_t num_bytes)
{
	int err;

	/* disable write protect */
	err = mb85rs64v_access(spi, spi_cfg,
			       MB85RS64V_WRITE_ENABLE_CMD, 0, NULL, 0);
	if (err) {
		printk(&amp;quot;unable to disable write protect\n&amp;quot;);
		return -EIO;
	}

	/* write cmd */
	err = mb85rs64v_access(spi, spi_cfg,
			       MB85RS64V_WRITE_CMD, addr, data, num_bytes);
	if (err) {
		printk(&amp;quot;Error during SPI write\n&amp;quot;);
		return -EIO;
	}

	return 0;
}

static int read_bytes(struct device *spi, struct spi_config *spi_cfg,
		      u16_t addr, u8_t *data, u32_t num_bytes)
{
	int err;

	/* read cmd */
	err = mb85rs64v_access(spi, spi_cfg,
			       MB85RS64V_READ_CMD, addr, data, num_bytes);
	if (err) {
		printk(&amp;quot;Error during SPI read\n&amp;quot;);
		return -EIO;
	}

	return 0;
}

void main(void)
{
	struct device *spi;
        struct device *gpio_dev;
	struct spi_config spi_cfg;
        struct spi_cs_control cs_control;
	int err;

	printk(&amp;quot;fujitsu FRAM example application\n&amp;quot;);

	spi = device_get_binding(&amp;quot;SPI_3&amp;quot;);
	if (!spi) {
		printk(&amp;quot;Could not find SPI 3 driver\n&amp;quot;);
		return;
	}else{
                printk(&amp;quot;SPI_3 %x\n&amp;quot;,spi);
        }

        gpio_dev = device_get_binding(&amp;quot;GPIO_0&amp;quot;);
        if(!gpio_dev) {
                printk(&amp;quot;could not find GPIO device\n&amp;quot;);
                return;
        }
        cs_control.delay = 0;
        cs_control.gpio_dev = gpio_dev;
        cs_control.gpio_pin = 22;
	spi_cfg.operation = SPI_WORD_SET(8);
	spi_cfg.frequency = 256000;
        spi_cfg.cs = &amp;amp;cs_control; 

while(1){
	err = mb85rs64v_read_id(spi, &amp;amp;spi_cfg);
	if (err) {
		printk(&amp;quot;Could not verify FRAM ID\n&amp;quot;);
		
	}
           }

	
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If it would help I can email you the entire project.&amp;nbsp; Nothing private in it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/167838?ContentTypeID=1</link><pubDate>Fri, 25 Jan 2019 09:19:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1570ee3-7505-4286-8991-3e467f724f69</guid><dc:creator>Jan Tore Guggedal</dc:creator><description>&lt;p&gt;Hi Jeff,&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;It would be useful to see what&amp;#39;s going on in your main.c files. That would make it easiuer to reproduce your setup locally.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/167641?ContentTypeID=1</link><pubDate>Thu, 24 Jan 2019 12:59:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adcd16ed-fa96-4a0a-a789-0361efb3dd64</guid><dc:creator>Jeff Seaman</dc:creator><description>&lt;p&gt;Have you tried anything with the SPI.&amp;nbsp; I also tryed the SPI under Zephyr on the nRF52840 with no results.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/167556?ContentTypeID=1</link><pubDate>Thu, 24 Jan 2019 08:33:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac41adad-e793-45ca-a207-a7db9fd9b779</guid><dc:creator>SindreSB</dc:creator><description>&lt;p&gt;I&amp;#39;d love to get a sample of this as well&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/166948?ContentTypeID=1</link><pubDate>Mon, 21 Jan 2019 16:39:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3e5830d-fe00-47c1-b875-555c6f72c449</guid><dc:creator>Jeff Seaman</dc:creator><description>&lt;p&gt;Martin&lt;/p&gt;
&lt;p&gt;I tried setting the project up on SPI 3 and configuring secure boot.&lt;/p&gt;
&lt;p&gt;the prj.conf for secure boot&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_TRUSTED_EXECUTION_SECURE=y
CONFIG_UART_1_NRF_UARTE=y
CONFIG_SPI_3_NRF_SPIM=y
# needed to get the NRF_UARTE2 define
CONFIG_UART_2_NRF_UARTE=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;the overlay for secure boot&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* needed to get the NRF_UARTE2 defined */
&amp;amp;uart1{
	current-speed = &amp;lt;38400&amp;gt;;
	tx-pin = &amp;lt;24&amp;gt;;
	rx-pin = &amp;lt;25&amp;gt;;
	cts-pin = &amp;lt;27&amp;gt;;
	rts-pin = &amp;lt;28&amp;gt;;

};

&amp;amp;uart2 {
	current-speed = &amp;lt;1000000&amp;gt;;
	status = &amp;quot;ok&amp;quot;;
	tx-pin = &amp;lt;18&amp;gt;;
	rx-pin = &amp;lt;17&amp;gt;;
	rts-pin = &amp;lt;19&amp;gt;;
	cts-pin = &amp;lt;21&amp;gt;;
};

&amp;amp;spi3 {
        status = &amp;quot;ok&amp;quot;;
        sck-pin = &amp;lt;26&amp;gt;;
        mosi-pin = &amp;lt;27&amp;gt;;
        miso-pin = &amp;lt;28&amp;gt;;
        spi-max-frequency = &amp;lt;4000000&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the prj.conf file for the application&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# General config
CONFIG_NEWLIB_LIBC=y

# Trusted execution
CONFIG_TRUSTED_EXECUTION_NONSECURE=y


CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

CONFIG_GPIO=y

CONFIG_SPI=y
CONFIG_SPI_NRFX=y
CONFIG_SPI_3=y
CONFIG_SPI_3_NRF_SPIM=y

CONFIG_PRINTK=y
CONFIG_HEAP_MEM_POOL_SIZE=256
CONFIG_ASSERT=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the overlay for the application&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi3 {
        status = &amp;quot;ok&amp;quot;;
        sck-pin = &amp;lt;26&amp;gt;;
        mosi-pin = &amp;lt;27&amp;gt;;
        miso-pin = &amp;lt;28&amp;gt;;
        spi-max-frequency = &amp;lt;4000000&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am still not seeing any activity on the SPI clock pin&lt;/p&gt;
&lt;p&gt;I will try your next suggestion&lt;/p&gt;
&lt;p&gt;Thanks for the Help&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problems with SPI on nRF9160 and Zephyr</title><link>https://devzone.nordicsemi.com/thread/166894?ContentTypeID=1</link><pubDate>Mon, 21 Jan 2019 14:57:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d3f037c-08ef-4383-9943-2392fc211518</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Jeff,&lt;/p&gt;
&lt;p&gt;When &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/0.3.0/nrf/ug_nrf9160.html"&gt;working with nrf9160 samples&lt;/a&gt;, it&amp;nbsp;has to be built as a non-secure firmware image.&lt;br /&gt;So that means that you need to add:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_TRUSTED_EXECUTION_NONSECURE=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;in the &lt;em&gt;prj.conf&lt;/em&gt; file for your application. I also recommend that you copy your .overlay file and add it in the &lt;strong&gt;secure_boot&lt;/strong&gt; sample and build/flash that again.&lt;/p&gt;
&lt;p&gt;(I assume that you are already using the &lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-zephyr/blob/master/drivers/spi/spi_nrfx_spim.c"&gt;&lt;em&gt;nrfx_spi driver&lt;/em&gt;&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;We do not have a sample for this yet, but I can see if I can make something for you if the pointers aren&amp;#39;t enough.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>