<?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>How to disable SPI and TWI communication without interrupting GPIO.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40442/how-to-disable-spi-and-twi-communication-without-interrupting-gpio</link><description>Hi 
 I am using nrf51822 , sdk version 11 and softdevice version 130 
 In project I am trying to disable SPI1 and TWI0 channel by using following command 
 NRF_TWI0-&amp;gt;ENABLE = TWI_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; TWI_ENABLE_ENABLE_Pos; 
 NRF_SPI1-&amp;gt;ENABLE = (SPI_ENABLE_ENABLE_Disabled</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Nov 2018 14:41:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40442/how-to-disable-spi-and-twi-communication-without-interrupting-gpio" /><item><title>RE: How to disable SPI and TWI communication without interrupting GPIO.</title><link>https://devzone.nordicsemi.com/thread/157553?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 14:41:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bf1c8eb-f681-40c9-a123-21f2ba167e21</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;OK, i would consider connecting the SDA and SCL lines of both sensor to one TWI bus so that you do not have to switch. If you do not want to do that then&amp;nbsp;&lt;span&gt;then&amp;nbsp;keep the OLED on SPI0&amp;nbsp;and then reinitialize the TWI1 instance every 100ms with the pin configuration of the sensor you want to use the next 100ms.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to disable SPI and TWI communication without interrupting GPIO.</title><link>https://devzone.nordicsemi.com/thread/157512?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 13:07:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05003850-e6d7-4d15-bd8b-c657b4fb68a0</guid><dc:creator>suvarna_kadam</dc:creator><description>&lt;p&gt;In my hardware Heart rate and Accelerometer using different pins as peripheral, so I could not use the same TWI channel for both.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to disable SPI and TWI communication without interrupting GPIO.</title><link>https://devzone.nordicsemi.com/thread/157436?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 09:16:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e783a3e8-4db3-4bed-b561-f4e72af5fa59</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Un-initializing the SPI and/or TWI peripheral should not affect any other peripherals like TIMERs and GPIO as they are instanced at other addresses that the SPI and TWI peripherals.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Why are you switching between the serial interfaces in the first place? You are aware that you can have multiple TWI slaves on a TWI bus?&lt;/p&gt;
&lt;p&gt;Why are you switching the OLED? I would just keep the OLED on SPI0 and then you connect both the&amp;nbsp;h&lt;span&gt;eart rate sensor and the&amp;nbsp;accelerometer&amp;nbsp;to the TWI1 bus. If the two sensors use different TWI frequencies, then I would just reinitialize the TWI1 instance every 100ms. This makes things less complicated.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Bjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to disable SPI and TWI communication without interrupting GPIO.</title><link>https://devzone.nordicsemi.com/thread/157404?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 06:40:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6791a633-2167-4d48-8830-46b09c040a2f</guid><dc:creator>suvarna_kadam</dc:creator><description>&lt;p&gt;Hi Bjorn&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I am using diferent pin for SPI and TWI peripheral as well as GPIOs.&lt;/li&gt;
&lt;li&gt;Our system works as follows&lt;br /&gt;2.1 OLED is on SPI1 , Accelerometer is on TWI0 for 100ms.&amp;nbsp;&lt;br /&gt;2.2 OLED is on SPI0, Heart rate sensor on TWI1 for next 100ms.&lt;br /&gt;&lt;br /&gt;we are doing this because of the following point mentioned in the nrf51 reference manual.&lt;br /&gt;&amp;#39;same peripheral base address cannot be used at the same time.&amp;#39;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Error:&amp;nbsp;&lt;/strong&gt;when we switch from point number 2.1 to 2.2, the other parts of the system stop working (Button and timer and GPIO functionality).&lt;/li&gt;
&lt;li&gt;Note: I have already tried with &lt;span&gt;nrf_drv_spi_uninit(), It was giving same problem mentioned in point 3.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;I have also tried&amp;nbsp;the following combinations mentioned in the code below.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//== SECTION FROM spi.c ==//
//====================== code to disable SPI ==============================

#if (SPI0_ENABLED == 1)
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(0); 
#elif (SPI1_ENABLED == 1)
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(1); 
#elif (SPI2_ENABLED == 1)
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(2); 
#else
#error &amp;quot;No SPI enabled.&amp;quot;
#endif

void disable_SPI()
{
	// === Method 1 ===//
	// nrf_drv_spi_uninit(&amp;amp;spi);
	
	// ===  Method 2 ===//
    //	nrf_drv_spi_disable(&amp;amp;spi)
    
	// ===  Method 3 ===//
	//NRF_SPIM_Type * p_spim = p_instance-&amp;gt;p_registers;
	//NRF_SPI1-&amp;gt;ENABLE = (SPIM_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SPIM_ENABLE_ENABLE_Pos);

	//=== Method 4 ===//
    NRF_SPI1-&amp;gt;ENABLE = 0;
}

//===========================================================================

&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//== SECTION FROM nrf_drv_spi.c file ==//
//============================================
// *** customised function for DISABLE SPI *** //
void nrf_drv_spi_disable(nrf_drv_spi_t const * const p_instance)
{
	// ==== only for method 2 ===//
	NRF_SPI_Type * p_spi = p_instance-&amp;gt;p_registers;
	nrf_spi_disable(p_spi);
	nrf_delay_ms(10);
}
//============================================
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What could be the problem?&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to disable SPI and TWI communication without interrupting GPIO.</title><link>https://devzone.nordicsemi.com/thread/157312?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 13:41:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1578c358-cfb6-4ebb-857c-86a49ca69490</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;HI Suvarna,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Firstly, if the drivers you are using are marked as deprecated then you should move to the latest drivers. We do not support deprecated SW.&lt;/p&gt;
&lt;p&gt;If you want to use the pins previously used by the SPI or TWI peripheral as GPIOs then you need to configure the GPIOs as outputs&amp;nbsp;after the SPI or TWI periheral has been disabled. Generally I would recommend to use the driver API to disable the peripherals, e.g. nrf_drv_twi_uninit().&lt;/p&gt;
&lt;p&gt;What errors do you get when you try to intialize the pins as outputs after disabling the TWI/SPI peripheral?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>