<?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>nRF5340: Unable to Access I2C with nRF connect SDK v.2.1.2</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93741/nrf5340-unable-to-access-i2c-with-nrf-connect-sdk-v-2-1-2</link><description>Hello, 
 
 I attached LIS2DS12 accelerometer sensor driver to the nrf5340 board, and I am trying to do (1) i2c access and (2) single tap interrupt handling (the sensor activates INT1 when tap event is detected). 
 1. nRF Connect SDK and toolchain version</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Nov 2022 22:06:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93741/nrf5340-unable-to-access-i2c-with-nrf-connect-sdk-v-2-1-2" /><item><title>RE: nRF5340: Unable to Access I2C with nRF connect SDK v.2.1.2</title><link>https://devzone.nordicsemi.com/thread/397283?ContentTypeID=1</link><pubDate>Wed, 23 Nov 2022 22:06:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6592659b-8c76-4248-bf43-1e1adf92b00a</guid><dc:creator>skim</dc:creator><description>&lt;p&gt;After checking the voltage, I was able to fix the issue. We can close this ticket.&amp;nbsp;Thank you!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Sincerely,&lt;/p&gt;
&lt;p&gt;SK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340: Unable to Access I2C with nRF connect SDK v.2.1.2</title><link>https://devzone.nordicsemi.com/thread/395929?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2022 09:47:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbdb8a84-bf5d-4710-9699-0d6717ff708c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The ST driver I mentioned can be used via the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.2/zephyr/hardware/peripherals/sensor.html"&gt;sensor subsystem &lt;/a&gt;as demonstrated by the&amp;nbsp; &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.2/zephyr/samples/sensor/accel_polling/README.html"&gt;Generic 3-Axis accelerometer polling sample&lt;/a&gt; and &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.2/zephyr/samples/sensor/lis2dh/README.html"&gt;LIS2DH: Motion Sensor Monitor&lt;/a&gt; sample. However, please note that these are for the LIS2D&lt;strong&gt;H &lt;/strong&gt;IC and not the &lt;span&gt;LIS2DS IC you use so you will need to adapt the sample (change compatible and node name) to ensure the build system includes the correct driver. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;From the specification I see the LIS2DS does not support supply voltages &amp;gt;1.98 V. Have you made sure the nRF5340 supply/IO voltage does not exceed this?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.st.com/en/mems-and-sensors/lis2ds12.html"&gt;https://www.st.com/en/mems-and-sensors/lis2ds12.html&lt;/a&gt; &lt;br /&gt;&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;Vidar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340: Unable to Access I2C with nRF connect SDK v.2.1.2</title><link>https://devzone.nordicsemi.com/thread/395888?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2022 01:00:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c66cb669-6850-42d4-8a50-654fb51ef483</guid><dc:creator>skim</dc:creator><description>&lt;p&gt;Hello, I edited overlay files following your suggestion, but unfortunately i2c still didn&amp;#39;twork with SDK 2.1.2. It still worked with SDK 2.0.0. Do you have any other suggestions?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, I enabled lis2dh12 driver. In the overlay file, we defined its i2c reg address (reg = &amp;lt;0x1d&amp;gt;). Is there any way to use this value instead of using hardcoded value in the code (#define ST_I2C_ADDR 0x1d)?&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define ST_I2C_ADDR 0x1d // hardcoded
#define ST_REG_WAI 0x0f
uint8_t wai = 0;
ret = read_reg_value(i2c_dev, ST_I2C_ADDR, ST_REG_WAI, &amp;amp;wai);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. DTS Overlay file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/  {

    // overwrite
    gpio_fwd: nrf-gpio-forwarder {
		compatible = &amp;quot;nordic,nrf-gpio-forwarder&amp;quot;;
		status = &amp;quot;okay&amp;quot;;
		uart {
			gpios = &amp;lt;&amp;amp;gpio1 1 0&amp;gt;, &amp;lt;&amp;amp;gpio1 4 0&amp;gt;, &amp;lt;&amp;amp;gpio0 11 0&amp;gt;, &amp;lt;&amp;amp;gpio0 10 0&amp;gt;;
		};
	};


    st_motion_interrupts {
        compatible = &amp;quot;gpio-keys&amp;quot;;

        st_int1 {
            gpios = &amp;lt; &amp;amp;gpio1 0x0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW) &amp;gt;;
            label = &amp;quot;st_lis2dh12_int1&amp;quot;;
        };
    };


};

&amp;amp;i2c1
{
    lis2dh12@1d {
        compatible = &amp;quot;st,lis2ds12&amp;quot;;
        reg = &amp;lt;0x1d &amp;gt;;
        label = &amp;quot;st_lis2dh12&amp;quot;;
    };
};

// overwrite - added bias-pull-up to i2c1_sleep.
&amp;amp;pinctrl {
    i2c1_default: i2c1_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(TWIM_SDA, 1, 2)&amp;gt;,
                &amp;lt;NRF_PSEL(TWIM_SCL, 1, 3)&amp;gt;;
                bias-pull-up; // added
        };
    };

    i2c1_sleep: i2c1_sleep {
        group1 {
            psels = &amp;lt;NRF_PSEL(TWIM_SDA, 1, 2)&amp;gt;,
                &amp;lt;NRF_PSEL(TWIM_SCL, 1, 3)&amp;gt;;
            low-power-enable;
        };
    };

};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Config (prj.conf) file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_GPIO=y
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_LIS2DS12=y&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Code&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;-&amp;nbsp;unchanged&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;Sincerely,&lt;/p&gt;
&lt;p&gt;SK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340: Unable to Access I2C with nRF connect SDK v.2.1.2</title><link>https://devzone.nordicsemi.com/thread/395087?ContentTypeID=1</link><pubDate>Thu, 10 Nov 2022 11:39:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54fdf997-0590-44b7-953f-a9f9202fa098</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;It&amp;#39;s strange that it worked fine with SDK v2.0.0 but not v2.1.0. I&amp;#39;m was not able to find any relevant changes between these 2 releases, at least.&lt;/p&gt;
&lt;p&gt;I think the easiest way to troubleshoot this further is if you could probe the SDA/SCL lines with a scope or logic analyzer if you have that. Also, in case you use the internal GPIO pull-ups, please make sure they have been enabled with the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/api/bindings/pinctrl/nordic,nrf-pinctrl.html"&gt;bias-pull-up&lt;/a&gt; property in in your devicetree.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; &amp;amp;pinctrl {
	i2c2_default: i2c2_default {
		group1 {
			psels = &amp;lt;NRF_PSEL(TWIM_SDA, 0, 30)&amp;gt;,
				&amp;lt;NRF_PSEL(TWIM_SCL, 0, 31)&amp;gt;;
				bias-pull-up;
		};
	};

	i2c2_sleep: i2c2_sleep {
		group1 {
			psels = &amp;lt;NRF_PSEL(TWIM_SDA, 0, 30)&amp;gt;,
				&amp;lt;NRF_PSEL(TWIM_SCL, 0, 31)&amp;gt;;
			low-power-enable;
		};
	};

};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And just in case you haven&amp;#39;t noticed, ST also include a driver for this IC in the SDK if you want to try it:&amp;nbsp; &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.2/zephyr/build/dts/api/compatibles/st,lis2ds12.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.2/zephyr/build/dts/api/compatibles/st,lis2ds12.html&lt;/a&gt;. To enable this driver you can select &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_LIS2DS12"&gt;CONFIG_LIS2DS12=y&lt;/a&gt; and add the lis2dh12 subnode to your i2c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c1
{
    lis2dh12@1d {
        compatible = &amp;quot;st,lis2ds12&amp;quot;;
        reg = &amp;lt;0x1d &amp;gt;;
    };
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>