<?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>nRF52840 TWI library error</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33912/nrf52840-twi-library-error</link><description>Hi, 
 I have included in my code the code from the twi_scanner example as a starting point for using TWI in my board. When compiling, I get the following error: 
 
 ../../../../../../integration/nrfx/legacy/nrf_drv_twi.h:120:37: error: &amp;#39;NRF_DRV_TWI_INSTANCE_0</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 May 2018 09:24:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33912/nrf52840-twi-library-error" /><item><title>RE: nRF52840 TWI library error</title><link>https://devzone.nordicsemi.com/thread/131326?ContentTypeID=1</link><pubDate>Tue, 08 May 2018 09:24:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7634553-647f-4682-ac5c-6c19debb162c</guid><dc:creator>adragocelestica</dc:creator><description>&lt;p&gt;In the end i found the way to make it work. I will explain in case someone else is in the same situation.&lt;/p&gt;
&lt;p&gt;Basically, I declare the SPI instances and the TWI instance, as you suggested. Then, in my sdk_config.h, I&amp;nbsp;add the following line:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#ifndef PERIPHERAL_RESOURCE_SHARING_ENABLED
#define PERIPHERAL_RESOURCE_SHARING_ENABLED 1 //https://devzone.nordicsemi.com/f/nordic-q-a/17035/twi0-and-spi0-time-multiplex
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I initialize the SPIs as in the peripherals/spi example. Then, when I want to use them, I do it like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;spi0_init();
spi0_xfer_done = false;
spi0_tx_buf[0]=0x01;
spi0_tx_buf[1]=0x8F;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi0, spi0_tx_buf, spi0_length, spi0_rx_buf, spi0_length));
while (!spi0_xfer_done)
{
	__WFE();
}
nrf_drv_spi_uninit(&amp;amp;spi0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This way, the code compiles and seems to do stuff. I am not getting the expected results, so something may be badly configured, but it is good as a starting point. Basically, I am initializing and uninitializing&amp;nbsp;the peripheral every time I use it because &lt;span style="background-color:#f6d5d9;"&gt;I&lt;/span&gt; cannot use TWI0 and SPI0 at the same time since they share the base address.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The SPI transaction seems to be executed, but what I receive in spi0_rx_buf is a long number (always the same number), regardless of what I am writing. If I am getting something wrong, please do not hesitate to correct me.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Alin O. Dragomir&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI library error</title><link>https://devzone.nordicsemi.com/thread/131046?ContentTypeID=1</link><pubDate>Fri, 04 May 2018 14:16:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c85bb28a-251a-4705-8f84-de7c5349f241</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;There is no examples in the SDK implementing 3 SPI instances, but you can easily enable this yourself in the default SPI example:&lt;/p&gt;
&lt;p&gt;In sdk_config.h, set SPI1_ENABLED and&amp;nbsp;SPI2_ENABLED to 1, in main, add two new instances on SPI1 and SPI2, in addition to the existing instance of SPI0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static const nrf_drv_spi_t spi0 = NRF_DRV_SPI_INSTANCE(0); /**&amp;lt; SPI instance 0. */
static const nrf_drv_spi_t spi1 = NRF_DRV_SPI_INSTANCE(1); /**&amp;lt; SPI instance 1. */
static const nrf_drv_spi_t spi2 = NRF_DRV_SPI_INSTANCE(2); /**&amp;lt; SPI instance 2. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI library error</title><link>https://devzone.nordicsemi.com/thread/130926?ContentTypeID=1</link><pubDate>Fri, 04 May 2018 07:16:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d273f59c-26e9-44c2-a865-71f4596bc6f2</guid><dc:creator>adragocelestica</dc:creator><description>&lt;p&gt;I am trying the same approach for SPI, that is, copying from the sdk_config.h file in the SPI example, but i still get the same compilation error.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;../../../../../../integration/nrfx/legacy/nrf_drv_spi.h:120:37: error: &amp;#39;NRF_DRV_SPI_INSTANCE_1&amp;#39; undeclared here (not in a function)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is there an sdk_config.h file that implements 3 SPI interfaces? I am implementing one right now, and I am having trouble, I don&amp;#39;t expect to be able to do it for 3 interfaces this way. Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI library error</title><link>https://devzone.nordicsemi.com/thread/130780?ContentTypeID=1</link><pubDate>Thu, 03 May 2018 10:47:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ec67f57-f988-4edf-b514-a2e44f5e9dd3</guid><dc:creator>adragocelestica</dc:creator><description>&lt;p&gt;the issue was in my sdk_config.h. What I did is profit from the fact that this file is written with &amp;quot;ifdefine&amp;quot;, and I just copied and pasted one after the other the code from different sdk_config.h files from different examples. That way, I only modified what was missing, and now the TWI is working. I will try to do the same for SPI, hopefully it will work too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI library error</title><link>https://devzone.nordicsemi.com/thread/130487?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 09:20:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c54e6026-c5e6-4946-b2ab-f0b9bf8a6459</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I&amp;#39;m not able to reproduce your exact issue, but it sounds like there is some wrong configuration in your sdk_config.h file. Please make sure you have set the NRFX_TWI/TWIM and TWI_ENABLED configs similar to the example:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-d3a316f8042d487aa4a2bbcf9a37a083/sdk_5F00_config_5F00_twi_5F00_scanner.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWI library error</title><link>https://devzone.nordicsemi.com/thread/130460?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 08:30:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c549a652-c206-4f26-9857-473aadb82052</guid><dc:creator>adragocelestica</dc:creator><description>&lt;p&gt;I am having the exact same problem with SPI, and I suspect it has something to do with sdk_config.h. I have backed up my project and tinkered a little with it, trying to copy and paste the parts that are missing in my sdk_config.h and that are present in the one in the example, but I still get the same result. I tried to use the big generic sdk_config.h from&amp;nbsp;\config\nrf52840\config , and I got different errors, so the solution to this one must have something to do with sdk_config.h yet I cannot figure out what it is.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>