<?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 SPI Loopback SDK 2.3.0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97960/nrf9160-spi-loopback-sdk-2-3-0</link><description>Overview 
 Hi 
 I have the nRF9160DK and I have had a really good experience with it so far getting MCU, Modem, LTE, GNSS, Logging and CoAP working. 
 The challenge is now that I have to connect another sensor development board, which needs to communicate</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Mar 2023 10:56:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97960/nrf9160-spi-loopback-sdk-2-3-0" /><item><title>RE: nRF9160 SPI Loopback SDK 2.3.0</title><link>https://devzone.nordicsemi.com/thread/418071?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2023 10:56:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:955f3655-5678-4954-8fa7-79134cb7de4f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Unfortunatly it&amp;#39;s not possible for pins to overlap functionality, even though I see the idea in this case. So you do need to use two sets of gpios for spi master and slave in this case (so a total of 8pins).&lt;/p&gt;
&lt;p&gt;Ref reason behind the&amp;nbsp;&amp;#39;spi-dev-a@0&amp;#39; { reg = &amp;lt;0&amp;gt;; }&amp;nbsp;&lt;/p&gt;
&lt;p&gt;See:&lt;br /&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/intro.html#unit-address-examples"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/intro.html#unit-address-examples&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;quot;An index representing the peripheral’s chip select line number. (If there is no chip select line, 0 is used.)&amp;quot;&lt;/p&gt;
&lt;p&gt;Also see:&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.2.99-ncs2/include/zephyr/devicetree/spi.h#L83"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.2.99-ncs2/include/zephyr/devicetree/spi.h#L83&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI Loopback SDK 2.3.0</title><link>https://devzone.nordicsemi.com/thread/417142?ContentTypeID=1</link><pubDate>Thu, 23 Mar 2023 14:34:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02cc4d1c-ec76-464e-b56a-6402456f2f88</guid><dc:creator>Logstor</dc:creator><description>&lt;p&gt;Hi Vidar, thanks for the answer! :)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Below is a screenshot of my serial terminal running baud 9600 as specified in the overlay for uart0. I flashed the same program to the board, but with CONFIG_RESET_ON_FATAL_ERROR=n. On initial reset the first two question marks, and then on another manual reset with reset button, then the other two came. For some reason it&amp;#39;s like it turns off the uart logging backend?&lt;/p&gt;
&lt;p&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/pastedimage1679576546395v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Regarding the DTS overlay pinout - I&amp;#39;ve just now read about the external memory, but I&amp;#39;m not using this, and I just planned to use that SPI interface in my loopback test. I guess that the external memory is turned off by default, so I&amp;#39;m free to use those SPI registers for communication with something else than the external memory?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve looked at your colleagues example, and I can see that I&amp;#39;ve done some things right, but there&amp;#39;s also a couple of things I don&amp;#39;t understand in his devicetree. Below is a screenshot of a small part of his devicetree, here I don&amp;#39;t understand why SPIS_CSN pin number(14) doesn&amp;#39;t match &amp;#39;cs-gpios&amp;#39; pin number(28). Is it because he connect pin 14 and 28 with a physical wire?&lt;/p&gt;
&lt;p&gt;Lastly, I dont understand the &amp;#39;reg_my_spi_master&amp;#39;. What does it do, and why is it necessary. I see it in his code, but unfortunately I still don&amp;#39;t get it? :)&lt;/p&gt;
&lt;p&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/pastedimage1679581296955v5.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Picture of my new devicetree overlay below. I&amp;#39;ve added the SPIS_CSN to the spi2 pinctrl, and added &amp;#39;cs-gpios&amp;#39; to the spi3 with the same pin number as SPIS_CSN, because I intend to not use any wires. If that&amp;#39;s possible of course.&lt;/p&gt;
&lt;p&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/pastedimage1679581765972v6.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think I need to get the logging to work, and then be sure my setup with no wires and spi2 and spi3 sharing pins is possible, before I update all the code and try again.&lt;/p&gt;
&lt;p&gt;Hope my answer makes sense &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/263a.svg" title="Relaxed"&gt;&amp;#x263a;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 SPI Loopback SDK 2.3.0</title><link>https://devzone.nordicsemi.com/thread/416834?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2023 13:53:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e00c8730-92bc-40f8-b40f-3db8a92c344a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]I have the nRF9160DK and I have had a really good experience with it so far getting MCU, Modem, LTE, GNSS, Logging and CoAP working.[/quote]
&lt;p&gt;I am happy to hear that you have had a good experience&amp;nbsp;with the kit so far.&lt;/p&gt;
&lt;p&gt;The chip select line must be&amp;nbsp;controlled dynamically be the SPIM&amp;nbsp;to allow the SPIS to operate.&amp;nbsp;If it is always asserted, the CPU will not be able to update the DMA buffer, see&amp;nbsp;&lt;a title="Semaphore operation" href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spis.html?cp=2_0_0_5_13_3#semaphore_abk_lbf_wr"&gt;Semaphore operation&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
[quote user=""]Is the described idea even possible?[/quote]
&lt;p&gt;Yes. A colleague of mine has made a SPI loopback example&amp;nbsp;which he has made available on Github:&amp;nbsp;&lt;a href="https://github.com/too1/ncs-spi-master-slave-example"&gt;https://github.com/too1/ncs-spi-master-slave-example&lt;/a&gt;. &amp;nbsp;&lt;/p&gt;
[quote user=""]In my current test logging through default, UART via USB doesn&amp;#39;t work.
&lt;ul&gt;
&lt;li&gt;Commenting out two lines with &amp;#39;spi_read_dt()&amp;#39; and &amp;#39;spi_write_dt()&amp;#39; makes logging work again for some reason.&lt;/li&gt;&lt;/ul&gt;[/quote]
&lt;p&gt;Without these lines commented, please try to build with&amp;nbsp;CONFIG_RESET_ON_FATAL_ERROR=n and see if you get a crashlog on UART.&lt;/p&gt;
[quote user=""]&lt;ul&gt;&lt;li&gt;Is my devicetree overlay file correct for this SPI configuration?
&lt;ul&gt;
&lt;li&gt;In general, my understanding of devicetrees struggles, especially the use of &amp;#39;pinctrl&amp;#39; over the deprecated miso-pin, mosi-pin etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;It looks to be OK. I was not able to spot any errors. But I am not sure about the pinout, are they not connected to the flash on your board (&lt;a title="The nRF9160 DK has a 64 Mb external flash memory. The memory is a multi-I/O memory supporting both SPIs." href="https://infocenter.nordicsemi.com/topic/ug_nrf91_dk/UG/nrf91_DK/external_memory.html"&gt;External memory&lt;/a&gt;)?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>