<?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>IO expander control with TWI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11916/io-expander-control-with-twi</link><description>Hello, 
 I&amp;#39;ve been trying to control MCP23017 IO expander with TWI using nRF52832. When I execute the code it stops at nrf_drv_twi_tx. The address pins A(0:2) are 0. 
 Any idea on what may not work here? 
 Code: 
 #define I2C_SCL_PIN (21)
#define</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Feb 2016 15:08:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11916/io-expander-control-with-twi" /><item><title>RE: IO expander control with TWI</title><link>https://devzone.nordicsemi.com/thread/45142?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2016 15:08:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e715fb1-2a4f-46b7-b03f-181709dcd3a9</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Glad it works! Updated my answer a little bit with some additional details.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IO expander control with TWI</title><link>https://devzone.nordicsemi.com/thread/45141?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2016 16:36:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76dcec81-f645-4c32-8f32-c9ecc43c4ffd</guid><dc:creator>Anunnaki</dc:creator><description>&lt;p&gt;I have changed the reset pin to an other pin, and the address to 0x20 (shift left was not necessary) and everything works!&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: IO expander control with TWI</title><link>https://devzone.nordicsemi.com/thread/45140?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2016 13:51:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40b1a796-7a06-4e9e-8f70-520a2a849c22</guid><dc:creator>Anunnaki</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Yes, I understand that the P0.21 is chip reset pin. However, I can&amp;#39;t change the TWI pins.&lt;/p&gt;
&lt;p&gt;Do i have to specifically instruct that that pin is not used as reset? If yes, how?
And if that would be the issue wouldn&amp;#39;t the chip just reset when i try to write something?&lt;/p&gt;
&lt;p&gt;Thank You!
Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IO expander control with TWI</title><link>https://devzone.nordicsemi.com/thread/45139?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2016 13:29:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76a8e7f5-91e8-4319-a187-72c572789553</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;First, pin 21 on the nRF52 is a chip &lt;a href="http://infocenter.nordicsemi.com/topic/nrf52.v1.7/Chunk279577127.html?cp=1_2_0_2#concept_r4r_4lr_2q"&gt;reset pin&lt;/a&gt; unless otherwise is configured in the &lt;code&gt;UICR-&amp;gt;PSELRESET&lt;/code&gt; &lt;a href="http://infocenter.nordicsemi.com/topic/nrf52.v1.7/Chunk1712815461.html?cp=1_2_0_11_0_59#register.PSELRESET-0"&gt;registers&lt;/a&gt;. So if possible try to use a different set of TWI pins.&lt;/p&gt;
&lt;p&gt;Second, when you don&amp;#39;t provide an event handler function to &lt;code&gt;nrf_drv_twi_init()&lt;/code&gt; the TWI driver will operate in blocking mode. I.e. if something goes wrong your application will get stuck in &lt;code&gt;nrf_drv_twi_tx()&lt;/code&gt;. In this case the blocking mode is probably not the issue though, but the pins that you use might be.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; When a pin is configured as a reset pin it is disconnected from other functionality, so your chip won&amp;#39;t reset whenever the TWI is active. What I think happens in your case is that: The SCL signal is routed to the reset pin, but the reset functionality overrules the TWI functionality. Hence, the TWI transaction fails and since you have configured the TWI module in blocking mode the code hangs in nrf_drv_twi_tx().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>