<?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>NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82724/nrf9160-and-lr1110-on-spi</link><description>Hi, I accidentally marked one of my own replies as the answer. 
 I&amp;#39;m trying to interface LR1110 (Dev Board) with NRF9160 DK using SPI. I have been working on this for a couple of weeks, explored almost the whole devzone, learned a lot, you guys are wonderful</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Dec 2021 13:06:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82724/nrf9160-and-lr1110-on-spi" /><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/344600?ContentTypeID=1</link><pubDate>Tue, 21 Dec 2021 13:06:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cbada3f-6edd-4ec6-a21a-68773f22d8cc</guid><dc:creator>Sohaib Qamar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the guidance, I am able to send SPI commands successfully on my DK board with LR1110.&lt;/p&gt;
&lt;p&gt;Now I need a BUSY signal from LR1110 to be read before making any SPI transactions for continuous communication using the LR1110 library. Secondly, I need one other Pin as Output for making the LR1110 Reset.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My question is how can I use these two pins (One as Input and the other as Output) in &lt;strong&gt;lr1110_hal.c&lt;/strong&gt; file.&lt;/p&gt;
&lt;p&gt;Do I need to define these Pins in .dts or .overlay file as well?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using the below code to initialize the Input pin, but the code gets stuck.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// This is my lr1110_hal.c file

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;logging/log.h&amp;gt;
#include &amp;lt;nrfx_spim.h&amp;gt;
#include &amp;lt;drivers/nrfx_errors.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;
#include &amp;quot;lr1110_hal.h&amp;quot;

const struct device *dev_gpio;
#define LR_BUSY_PIN 13

void setup_spim(void)
{
   	nrfx_spim_config_t spi_config = 	NRFX_SPIM_DEFAULT_CONFIG(
		NRFX_SPIM_SCK_PIN, 
		NRFX_SPIM_MOSI_PIN,
		NRFX_SPIM_MISO_PIN,
		NRFX_SPIM_SS_PIN);
   	printk(&amp;quot;Setting SPI\n&amp;quot;);
	//uint32_t err = nrfx_spim_init(&amp;amp;spi, &amp;amp;spi_config, spim_event_handler, NULL);
	uint32_t err = nrfx_spim_init(&amp;amp;spi, &amp;amp;spi_config, NULL, NULL);
	if (err == NRFX_ERROR_INVALID_STATE) {
		printk(&amp;quot;nrfx INIT NRFX_ERROR_INVALID_STATE\n&amp;quot;);
		return;
	}
	if (err == NRFX_ERROR_BUSY) {
		printk(&amp;quot;nrfx INIT NRFX_ERROR_BUSY\n&amp;quot;);
		return;
	}
	if (err == NRFX_ERROR_NOT_SUPPORTED) {
		printk(&amp;quot;nrfx INIT NRFX_ERROR_NOT_SUPPORTED\n&amp;quot;);
		return;
	}
	if (err != NRFX_SUCCESS) {
		printk(&amp;quot;nrfx INIT err: %d\n&amp;quot;, err);
		return;
	}
   	printk(&amp;quot;SPI SET\n&amp;quot;);
	
	int retErr;
	retErr = gpio_pin_configure(dev_gpio, LR_BUSY_PIN, GPIO_INPUT);
	if(retErr != 0) {
		printk(&amp;quot;GPIO config err.\n&amp;quot;);
		return;
	}
}

void testInput()
{
    int isPinActive = gpio_pin_get(dev_gpio, LR_BUSY_PIN);
    printk(&amp;quot;Pin: %d - isActive: %d\n&amp;quot;, LR_BUSY_PIN, isPinActive);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The above functions are being called by the &lt;strong&gt;main.c&lt;/strong&gt; file.&lt;/p&gt;
&lt;p&gt;What else do I need to add for initializing the GPIO Input pin and what do I need to add further for Output Pin.&lt;/p&gt;
&lt;p&gt;Thanks in Advance&lt;/p&gt;
&lt;p&gt;--&lt;br /&gt;Regards&lt;br /&gt;Sohaib&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/344571?ContentTypeID=1</link><pubDate>Tue, 21 Dec 2021 11:32:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24617d4e-057b-435d-b9c4-15cd02b7af93</guid><dc:creator>&amp;#216;yvind</dc:creator><description>[quote user="Sohaib"]I can change the CS signal now manually, my SPI is working when I toggle the CS signal manually before executing[/quote]
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spim.html"&gt;Please note that SPIM peripheral of the nRF9160 &lt;/a&gt;&lt;span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spim.html"&gt;does not implement support for chip select directly&lt;/a&gt;. Therefore, the CPU must use available GPIOs to select the correct slave and control this independently of the SPI master. The SPIM supports SPI modes 0 through 3. The CONFIG register allows setting CPOL and CPHA appropriately.&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;Have a look at this thread on DevZone:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/70105/how-to-use-spi-interface-in-a-zephyr-sample-example"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/70105/how-to-use-spi-interface-in-a-zephyr-sample-example&lt;/a&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: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343832?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 10:12:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed8dd167-2a48-43aa-aa22-3aa9c6274ca8</guid><dc:creator>Sohaib Qamar</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;&amp;Oslash;yvind,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have checked the schematics of my board 0.8.3 and flashed Hello Word with a changed overlay file in&amp;nbsp;nRF52840. I can change the CS signal now manually, my SPI is working when I toggle the CS signal manually before executing&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;nrfx_err_t ret = nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0);&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Secondly, below statement Turn CS line LOW instead of HIGH&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;gpio_pin_set(gpiodev, PIN, true);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Looking for recommendations, how my SPI can work without manual control of CS line.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;--&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Sohaib&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343383?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 12:01:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fae4d7c7-b4ce-4c07-87f4-9f9b0885a175</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
[quote user="Sohaib"]do I need to change the board controller firmware in order to run SPI on any available PINs of NRF9160 -DK?[/quote]
&lt;p&gt;No, if you change your pins to available pins on the DK, that are not connected through the board controller, you should be good.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343379?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 11:34:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7de1c4d7-f8c3-44de-9717-6c4736506bb5</guid><dc:creator>Sohaib Qamar</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;&amp;Oslash;yvind,&lt;br /&gt;Thank you for the detailed reply.&lt;br /&gt;Just curious, do I need to change the board controller firmware in order to run SPI on any available PINs of NRF9160 -DK? Let&amp;#39;s say if I change the pins as SCK (P0.30), MISO&amp;nbsp;(P0.27), MOSI&amp;nbsp;(P0.31) &amp;amp; CS&amp;nbsp;(P0.12).&amp;nbsp;&lt;br /&gt;--&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343364?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 10:36:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f47ac21-d101-4c60-a998-92baa0c1ac58</guid><dc:creator>&amp;#216;yvind</dc:creator><description>[quote user="Sohaib"]NRF9160 DK board is PCA10090, 0.8.3, 2019-1[/quote]
&lt;p&gt;First of all, version 0.8.3 of the nRF9160DK is fairly outdated and should be considered replaced with a newer version (currently at 1.0.1)&lt;/p&gt;
[quote user="Sohaib"]Where do I have to change the EXT_MEM_CTRL?[/quote]
&lt;p&gt;The board controller is an n&lt;span&gt;RF52840 SoC that is used to route some of the nRF9160 SiP pins to different components on the DK, such as LEDs and buttons, and to specific pins of the nRF52840 SoC itself. For a complete list of all the routing options available, see the&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf91_dk/UG/nrf91_DK/board_controller.html"&gt;nRF9160 DK board control section in the nRF9160 DK User Guide&lt;/a&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The &lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf91_dk/UG/nrf91_DK/nrf52840.html"&gt;nRF52840 is another physical device&lt;/a&gt; on the development kit that you need to program, following the steps provided in the nRF9160 DK User Guide, and the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/zephyr/boards/arm/nrf9160dk_nrf52840/doc/index.html#board-controller-firmware"&gt;board controller firmware chapter&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As stated in the latter link, you can program the board controller with the Hello World sample. You will need to add a&amp;nbsp;nrf9160dk_nrf52840.overlay with the following:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;external_flash_pins_routing {
        status = &amp;quot;okay&amp;quot;;
};&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343348?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 09:44:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f739376b-53d8-4dfd-990c-78e4fdd19ef6</guid><dc:creator>Sohaib Qamar</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/lr1110_5F00_test.rar"&gt;devzone.nordicsemi.com/.../lr1110_5F00_test.rar&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Attached is the project for LR1110 I&amp;#39;m trying to run.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343342?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 09:33:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ced5d56e-1ff0-48e9-89b9-8b50bbc81390</guid><dc:creator>Sohaib Qamar</dc:creator><description>[quote userid="77062" url="~/f/nordic-q-a/82724/nrf9160-and-lr1110-on-spi/343338#343338"]Did you follow instructions provided in my initial comment?[/quote]
&lt;p&gt;I am still unable to get it, I have read the links you provided.&lt;br /&gt;Where do I have to change the EXT_MEM_CTRL?&lt;br /&gt;I&amp;#39;m using overlay file for SPI &amp;amp; CS control.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343338?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 09:21:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8babd4a0-7c39-4445-bbf4-6ab8829f07da</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Did you follow instructions provided in my initial comment?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;More informatiion can be found&amp;nbsp;in the&amp;nbsp;&lt;/span&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/nrf/ug_nrf9160.html#board-controller"&gt;Board Controller chapter under Working with nRF91 series&lt;/a&gt;&lt;span&gt;, which is further explained in the&amp;nbsp;&lt;/span&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/zephyr/boards/arm/nrf9160dk_nrf52840/doc/index.html#nrf9160dk-board-controller-firmware"&gt;board controller chapter of nRF9160 board definition in Zephyr&lt;/a&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343317?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 08:15:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ec679e7-7408-4775-981c-269b12327964</guid><dc:creator>Sohaib Qamar</dc:creator><description>&lt;p&gt;&lt;span&gt;My NRF9160 DK board is PCA10090, 0.8.3, 2019-1.&lt;br /&gt;I&amp;#39;m using a version of nRF Connect SDK&amp;nbsp;v1.5.0.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343314?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 08:09:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff2b4837-d36a-406a-968f-b3be80657996</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;What version the nRF9160 DK are you using? What version of nRF Connect SDK are you using?&lt;/p&gt;
&lt;p&gt;From the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf91_dk/UG/nrf91_DK/board_controller.html"&gt;nRF9160 DK board control chapter&lt;/a&gt;&amp;nbsp;in the nRF9160 DK User Guide.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1447.pastedimage1639406098862v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 and LR1110 on SPI</title><link>https://devzone.nordicsemi.com/thread/343231?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 14:38:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:188d820d-c30d-45f2-8e01-3544ce2ff0c7</guid><dc:creator>Sohaib Qamar</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/oyvind-schei"&gt;Øyvind&lt;/a&gt; Apologies, I marked my reply as an answer so couldn&amp;#39;t open that again. Waiting for your answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>