<?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>change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65900/change-sda-and-scl-pin-for-i2c1-on-nrf5340</link><description>Hi, 
 
 I am using i2c driver available with zephr as i2c master. This is working fine. 
 I want to change the pins to P0.02 for SCL and P0.03 for SDA. I see multiple questions on similar line that indicates that this configuration should be possible</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 15 Sep 2020 13:27:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65900/change-sda-and-scl-pin-for-i2c1-on-nrf5340" /><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269678?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 13:27:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:107daf17-f220-4c9d-a2c0-9e4cfd194716</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello again!&lt;br /&gt;&lt;br /&gt;I miswrote when I said I got it to work with pins P0.02 and P0.02. The DK requires some modifications to support the NFC pins as conventional GPIOs, as described below:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;Pins&amp;nbsp;&lt;span&gt;W1&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span&gt;AA1&lt;/span&gt;&amp;nbsp;are by default configured to use the&amp;nbsp;&lt;a title="A standards-based short-range wireless connectivity technology that enables two electronic devices to establish communication by bringing them close to each other." href="https://infocenter.nordicsemi.com/topic/ug_nrf5340_pdk/dita_common/glossary/glossary.html#nfc"&gt;&lt;dfn&gt;NFC&lt;/dfn&gt;&lt;/a&gt;&amp;nbsp;antenna, but if they are needed as normal GPIOs,&amp;nbsp;&lt;span&gt;R43&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span&gt;R46&lt;/span&gt;&amp;nbsp;must be NC and&amp;nbsp;&lt;span&gt;R42&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span&gt;R45&lt;/span&gt;&amp;nbsp;must be shorted by&amp;nbsp;&lt;span&gt;0R&lt;/span&gt;.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This is described &lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf5340_pdk/UG/nrf5340_PDK/hw_nfc_if.html"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Carl Richard&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269667?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 12:50:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb7eb690-882e-45ef-bd76-3610d112d28a</guid><dc:creator>Divya BM</dc:creator><description>&lt;p&gt;Hi Carl!&lt;/p&gt;
&lt;p&gt;You are correct. Everything is the same except for&amp;nbsp;&lt;em&gt;&lt;span&gt;&lt;strong&gt;nrf5340pdk_nrf5340_cpuapp.overlay:&lt;/strong&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;amp;i2c1 {
	status = &amp;quot;ok&amp;quot;;
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	sda-pin = &amp;lt; 3 &amp;gt;;
	scl-pin = &amp;lt; 2 &amp;gt;;
    clock-frequency = &amp;lt;I2C_BITRATE_STANDARD&amp;gt;; 
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Divya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269646?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 12:12:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3213a1c8-9d81-4b65-9749-456e327b744b</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello, again!&lt;br /&gt;&lt;br /&gt;How does your prj.conf look?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The following are my I2C settings, see if yours match.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;prj.conf:&lt;/strong&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;# I2C
CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_I2C_1=y
CONFIG_NRFX_TWIM1=y

CONFIG_NFCT_PINS_AS_GPIOS=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span&gt;&lt;strong&gt;nrf5340pdk_nrf5340_cpuapp.overlay:&lt;/strong&gt;&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c1 {
	status = &amp;quot;okay&amp;quot;;
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	sda-pin = &amp;lt;33&amp;gt;;
	scl-pin = &amp;lt;34&amp;gt;;
	clock-frequency = &amp;lt;I2C_BITRATE_STANDARD&amp;gt;; 
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;main.c (extract):&lt;br /&gt;&lt;/strong&gt;&lt;pre class="ui-code" data-mode="text"&gt;void main(void)
{
	printk(&amp;quot;The I2C test started\n&amp;quot;);
    struct device *i2c_dev;
	int error;

    i2c_dev = device_get_binding(&amp;quot;I2C_1&amp;quot;);
    if (!i2c_dev) {
        printk(&amp;quot;Binding failed.&amp;quot;);
        return;
    }
    i2c_configure(i2c_dev, I2C_SPEED_SET(I2C_SPEED_STANDARD));
    
//(...) 
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269636?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 11:39:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6f9d4f2-5fc1-4144-8fc4-fbd0ce705113</guid><dc:creator>Divya BM</dc:creator><description>&lt;p&gt;Hi Carl!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I added &amp;quot;CONFIG_NFCT_PINS_AS_GPIOS=y&amp;quot; in &amp;quot;prj.conf&amp;quot; and&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;sda-pin = &amp;lt; 3 &amp;gt;;//&lt;span&gt;P0.3&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;scl-pin = &amp;lt; 2 &amp;gt;;//&lt;span&gt;P0.2&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span&gt;in &amp;quot;&lt;strong&gt;nrf5340pdk_nrf5340_cpuapp.overlay&lt;/strong&gt;&amp;quot;.&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/em&gt;However,&amp;nbsp;i2c_transfer fails as follows:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;&amp;nbsp;&amp;lt;err&amp;gt; i2c_nrfx_twim: Error 195952641 occurred for message&amp;quot;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Is there any other change required?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Divya B M&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269626?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 10:58:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2b95b1b-713f-47fb-a2bc-f9f033a73028</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hi again, Divya!&lt;br /&gt;&lt;br /&gt;Add the following to your prj.conf:&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NFCT_PINS_AS_GPIOS=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;With fairly low I2C frequency it should work fine!&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269502?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 04:36:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc06ea71-d20d-458c-a529-df4aee144b5c</guid><dc:creator>Divya BM</dc:creator><description>&lt;p&gt;Hi Carl!,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I see that the NFC pins(P0.02 and P0.03) can also be used as GPIO pins. The documentation states &amp;quot; &lt;em&gt;The pins dedicated to the NFCT antenna function will have some limitation when the pins are configured&lt;br /&gt;for normal GPIO operation&lt;/em&gt;&amp;quot;. So, there should be a way to use these pins as well for i2c1. Is there any configuartion to set these NFC pins as GPIO pins?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Divya B M&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269439?ContentTypeID=1</link><pubDate>Mon, 14 Sep 2020 14:36:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:965cac29-8bb6-426b-9fe9-f781de69722f</guid><dc:creator>Divya BM</dc:creator><description>&lt;p&gt;ok great! Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269437?ContentTypeID=1</link><pubDate>Mon, 14 Sep 2020 14:34:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:835ba0c4-ba34-480e-92a7-e86423ff66c9</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;My apologies. I gave you the wrong pin numbers!&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I must ask internally about available pins. Will come back to you tomorrow.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269426?ContentTypeID=1</link><pubDate>Mon, 14 Sep 2020 14:23:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7efd92f8-e9c9-4b28-a7e6-37cab1d0a135</guid><dc:creator>Divya BM</dc:creator><description>&lt;p&gt;Hi Carl!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In&amp;nbsp;&lt;strong&gt;nrf5340pdk_nrf5340_cpuapp.overlay,&amp;nbsp;&lt;/strong&gt;changing&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt; sda-pin = &amp;lt; 33 &amp;gt;;&lt;/em&gt;&lt;br /&gt;&lt;em&gt; scl-pin = &amp;lt; 34 &amp;gt;;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;to&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt; sda-pin = &amp;lt; 34 &amp;gt;;//&lt;span&gt;P1.2&lt;/span&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt; scl-pin = &amp;lt; 35 &amp;gt;;//&lt;span&gt;P1.3&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;helped.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also, since you mentioned&amp;nbsp;&lt;/p&gt;
[quote userid="68044" url="~/f/nordic-q-a/65900/change-sda-and-scl-pin-for-i2c1-on-nrf5340/269378"]The pins P0.02 and P0.03 are dedicated to NFC on the DK, so using them could yield erroneous behavior[/quote]
&lt;p&gt;we have a restriction on the number of gpio pins that are free. So, can we use any other GPIO pin with digital i/o as SDA and SCL pin for i2c?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Divya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269410?ContentTypeID=1</link><pubDate>Mon, 14 Sep 2020 13:54:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:080c3e46-a2a6-4dcd-a0cc-122105a024cf</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello, Divya!&lt;br /&gt;&lt;br /&gt;Could you try to add the following to your prj.conf:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NRFX_TWIM1=y
CONFIG_I2C_NRFX=y&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Hope that will work!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269391?ContentTypeID=1</link><pubDate>Mon, 14 Sep 2020 13:19:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a82bd27-2032-4be0-978d-b4119e615e77</guid><dc:creator>Divya BM</dc:creator><description>&lt;p&gt;Hi Carl!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the quick response.&amp;nbsp;&lt;/p&gt;
[quote userid="68044" url="~/f/nordic-q-a/65900/change-sda-and-scl-pin-for-i2c1-on-nrf5340/269378"]You can just add the file&amp;nbsp;&lt;strong&gt;nrf5340pdk_nrf5340_cpuapp.overlay&lt;/strong&gt; in your project directory[/quote]
&lt;p&gt;I tried this. I see that the value reflects correctly in &amp;quot;devicetree_unfixed.h&amp;quot; generated file as follows:&amp;nbsp;&lt;br /&gt;#define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_P_sda_pin 33&lt;br /&gt;#define DT_N_S_soc_S_peripheral_50000000_S_i2c_9000_P_scl_pin 34&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However, when i make the corresponding connections, i2c_transfer fails as follows:&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;nbsp;&amp;lt;err&amp;gt; i2c_nrfx_twim: Error 195952641 occurred for message&amp;quot;.&lt;/p&gt;
&lt;p&gt;My prj.conf file is:&lt;br /&gt;&lt;em&gt;CONFIG_I2C=y&lt;/em&gt;&lt;br /&gt;&lt;em&gt;CONFIG_I2C_1=y&lt;/em&gt;&lt;br /&gt;&lt;em&gt;CONFIG_SENSOR=y&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Am i missing something else? Any help with this will be useful. Thanks in advance!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Divya B M&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change sda and scl pin for i2c1 on nrf5340</title><link>https://devzone.nordicsemi.com/thread/269378?ContentTypeID=1</link><pubDate>Mon, 14 Sep 2020 12:58:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91d0fa84-8bc0-42c3-83dc-f48e0d9fc476</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello, Divya!&lt;br /&gt;&lt;br /&gt;The pins P0.02 and P0.03 are dedicated to NFC on the DK, so using them could yield erroneous behavior. According to the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/pin.html?cp=3_0_0_8_0"&gt;nRF5340 documentation&lt;/a&gt;&amp;nbsp;pin P1.2 and P1.3 should be suitable for TWI.&lt;br /&gt;I also want to add tht recommend using an overlay when configuring peripherals in NCS. You can just add the file&amp;nbsp;&lt;strong&gt;nrf5340pdk_nrf5340_cpuapp.overlay&lt;/strong&gt; in your project directory, with the following contents:&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c1 {
	status = &amp;quot;ok&amp;quot;;
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	sda-pin = &amp;lt; 33 &amp;gt;;
	scl-pin = &amp;lt; 34 &amp;gt;;
    clock-frequency = &amp;lt;I2C_BITRATE_STANDARD&amp;gt;;  
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Make sure that Prj.conf is configured correctly aswell.&lt;br /&gt;&lt;br /&gt;Let me know if this works for you or not.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>