<?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>Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34074/two-spi-and-one-i2c-master-on-nrf51</link><description>Hi, 
 I have a custom board someone designed with two SPI masters and one I2C master. We&amp;#39;re now trying to enable the second SPI master and I&amp;#39;m running into errors because you cannot enable SPI1 when TW1 is enabled. 
 So the simple question is can I use</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 May 2018 08:18:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34074/two-spi-and-one-i2c-master-on-nrf51" /><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/132912?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 08:18:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6eed49f-cc04-4194-a52a-8f8c7edfbce7</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I see,&amp;nbsp;PERIPHERAL_RESOURCE_SHARING_ENABLED was first introduced in SDK 11.0.0.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;This should be fine, this is check is ignored in SDK 11 if&amp;nbsp;PERIPHERAL_RESOURCE_SHARING_ENABLED is set.&lt;/li&gt;
&lt;li&gt;As long as you make sure you do not enable TWI and SPI at the same time, and keep track of which peripheral is enabled at any time, I think this workaround should work. I would anyway recommend you to have a look at SDK 11 to see how&amp;nbsp;PERIPHERAL_RESOURCE_SHARING_ENABLED is implemented here.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/132535?ContentTypeID=1</link><pubDate>Fri, 18 May 2018 19:43:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03dcdc43-a234-4a73-a8d7-ad2c69dd258f</guid><dc:creator>mstanisz</dc:creator><description>&lt;p&gt;Hey Jorgen,&lt;/p&gt;
&lt;p&gt;Yea I don&amp;#39;t have a&amp;nbsp;&lt;span&gt;PERIPHERAL_RESOURCE_SHARING_ENABLED in my nrf_drv_config.h file, nor do I see it anywhere in the SDK files.&amp;nbsp; I&amp;#39;m on an old SDK version (v10.0) since that&amp;#39;s what the customer was using and unfortunately cannot upgrade.&lt;br /&gt;&lt;br /&gt;My current hack is to set &lt;strong&gt;SP1_ENABLED&lt;/strong&gt; in my nrf_drv_config.h and modify the following files:&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;b&gt;&lt;/b&gt;&lt;span&gt;&lt;/span&gt;&lt;strong&gt;1) Disable the warning about turning on I2C1 and SPI1 at the same time in components\drivers_nrf\config\nrf_drv_config_validation.h:&lt;/strong&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//#if (TWI1_ENABLED+SPI1_ENABLED)&amp;gt;1
//#error &amp;quot;TWI1, SPI1 or TWIS1 cannot be enabled together. Peripherals overlaps.&amp;quot;
//#endif&lt;/pre&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2) Not initialize the SPI1 IRQ handler (since the I2C1 is the same pointer and already initialized) in components\drivers_nrf\spi_master\nrf_drv_spi.c:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//#if (SPI1_ENABLED == 1)
//void SPI1_IRQ_HANDLER(void)
//{
//    #if (SPI1_USE_EASY_DMA == 1)
//        irq_handler_spim(NRF_SPIM1,
//    #else
//        irq_handler_spi(NRF_SPI1,
//    #endif
//            &amp;amp;m_cb[SPI1_INSTANCE_INDEX]);
//}
//#endif // (SPI1_ENABLED == 1)&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m not sure if this is a decent workaround, especially due to #2 above.&amp;nbsp;&amp;nbsp;I was concerned that I might be missing SPI transactions because I&amp;#39;m not listening to the interrupt, but if I try to initialize the SPI1 IRQ, it complains that it&amp;#39;s already initialized for I2C1, so I was hoping since they&amp;#39;re on the same ISR pointer this workaround is possible.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I seem to be able to now uninitialize I2C1, initialize SPI1 and get SPI1 transactions back and forth with the hack above, so I think it&amp;#39;s working, but would love your input on this and a proper fix if there is one.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Matt&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/131903?ContentTypeID=1</link><pubDate>Mon, 14 May 2018 14:03:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5a9932e-de0d-470a-8631-8754c04c28f9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Have you set&amp;nbsp;PERIPHERAL_RESOURCE_SHARING_ENABLED to 1 in your nrf_drv_config.h file? Which SDK version are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/131577?ContentTypeID=1</link><pubDate>Wed, 09 May 2018 17:07:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f34ebaee-56b4-47a3-9257-db70bcc88942</guid><dc:creator>mstanisz</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;J&amp;oslash;rgen,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;That makes sense, but I think my case is different because I want to do the following:&lt;br /&gt;&lt;br /&gt;1) Initialize SPI0, I2C1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2) Uninitialize I2C1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3) Initialize SPI1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So instead of uninitializing/initializing SPI, I want to uninitialize the I2C1 instance and initialize a SPI1 instance.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve gotten through uninitializing I2C, but the issue with starting a second SPI is that my #defines in nrf_drv_config.h have SPI1_ENABLED = 0, so all the SPI driver indicies, interrupt settings, etc are not set up for SPI1.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What&amp;#39;s your recommendation for the cleanest way to transition from one to two SPI instances like this?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Matt&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/131444?ContentTypeID=1</link><pubDate>Wed, 09 May 2018 07:47:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52ab3670-0d5c-44aa-bfc4-29ead8d87616</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If you look into the source of nrf_drv_spi_init, you can see that the pins are configured with correct GPIO settings, the HAL function only set the correct pin number in the peripheral. You could configure the second set of GPIOs in your application, and set it in the peripheral using the HAL function, but you need to make sure the peripheral is not busy when doing this.&lt;/p&gt;
&lt;p&gt;Also note that you need to control SS pin manually in case of switching SPI pins (set it to NRF_DRV_SPI_PIN_NOT_USED in the config). This pin is controlled as a standard GPIO by the driver.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/131432?ContentTypeID=1</link><pubDate>Wed, 09 May 2018 03:21:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddf160c4-3aaa-4b5c-b146-6e8a0ed8300a</guid><dc:creator>mstanisz</dc:creator><description>&lt;p&gt;&lt;span&gt;Hey&amp;nbsp;J&amp;oslash;rgen,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;That&amp;#39;s what I figured about using the two sets of pins.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As for uninit and init of the SPI driver, are you saying that this is not possible by using the HAL driver because they&amp;#39;re also configured in the driver?&amp;nbsp; I&amp;#39;m confused by your last statement.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Matt&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/131393?ContentTypeID=1</link><pubDate>Tue, 08 May 2018 15:27:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfeac418-1ec1-4662-af26-cd978d5bbbb0</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Do you mean output the SPI signals to two set of pins at the same time? This is not supported by the peripheral without physically connecting the pins together.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You need to uninit and init the SPI driver in order to switch pins. Unfortunately, the pins are configured inside the driver and not only using &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.3.0/group__nrf__spi__hal.html?cp=4_0_6_6_6_30_0_16#ga12b3d35de73bf66c601cb5c6460a5868"&gt;SPI HAL function&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/131246?ContentTypeID=1</link><pubDate>Mon, 07 May 2018 15:05:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75765bbb-7702-49b9-adba-ad88255f5aca</guid><dc:creator>mstanisz</dc:creator><description>&lt;p&gt;Hey&amp;nbsp;J&amp;oslash;rgen,&lt;/p&gt;
&lt;p&gt;Thanks, I appreciate it.&amp;nbsp; I was afraid of that.&amp;nbsp; Another thought I had was running SPI0 out two sets of SPI pins.&amp;nbsp; Is that possible?&amp;nbsp; I&amp;#39;m guessing not, but worth a shot.&lt;/p&gt;
&lt;p&gt;Also, do you have a sample of switching between SPI ports?&amp;nbsp; All the config is in the initial nrf_drv_config.h, so I wasn&amp;#39;t sure how to actively switch ports once it&amp;#39;s initialized.&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Matt&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Two SPI and one I2C master on nRF51</title><link>https://devzone.nordicsemi.com/thread/131164?ContentTypeID=1</link><pubDate>Mon, 07 May 2018 09:36:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f00f34c-b900-4e46-89a5-a12426344206</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately, it is not possible to use two SPI intances and one TWI instance simultaneously on nRF51 series. The &lt;a href="http://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.1.pdf#page=17"&gt;serial instances share the same base address&lt;/a&gt;. It is possible to use alle three, but you will have to switch between them (disable one SPI to enable TWI, etc).&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>