<?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>Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79433/excessive-power-usage-when-using-i2c-twi</link><description>Hi We are developing a project where we are using a peripheral over i2c, specifically a lis3dh accelerometer. However we have encountered a problem and would be really grateful for any help you could provide. 
 Whenever we start to read or write to the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 27 Sep 2021 12:03:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79433/excessive-power-usage-when-using-i2c-twi" /><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/331297?ContentTypeID=1</link><pubDate>Mon, 27 Sep 2021 12:03:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e09f0ed8-e389-4500-9d6b-eccab6bd7c67</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;According to our developers, this issue should also be fixed in NCS v1.6.0, where a new config option is available for the nRF GPIO driver in Zephyr. It allows avoiding the use of GPIOTE for generation of the edge triggered interrupts, please see &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/a62ea8fa297a12c2d17332218ff45c1e54c55a8e/drivers/gpio/Kconfig.nrfx#L43-L58"&gt;GPIO_NRF_INT_EDGE_USING_SENSE&lt;/a&gt;&amp;nbsp;for details. Using this option should help keep the current consumption low in your case.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/330499?ContentTypeID=1</link><pubDate>Tue, 21 Sep 2021 13:21:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73ecaa1c-5d6a-4c78-9fd0-6e6bfa43d468</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It took a while and some discussion with my colleagues, but it seems like we&amp;#39;ve gotten to the bottom of it. There seems to be some strange bug wherethe I2C driver doesn&amp;#39;t handle the errata 89 workaround after your&amp;nbsp;&lt;strong&gt;accReadRegister()&lt;/strong&gt; function when the GPIO edge trigger is set. When reproducing this, we saw that commenting out the &lt;strong&gt;accReadRegister()&lt;/strong&gt; function from the main loop also put the current consumption back to normal, and implementing the errata 89 workaround after the &lt;strong&gt;accReadRegister()&lt;/strong&gt; function put the device back down to ~20uA. I have reported this bug internally, so the developers will take a look at it and fix this for a future release of the NCS.&lt;/p&gt;
&lt;p&gt;So the workaround here will be to, immediately after the &lt;strong&gt;accReadRegister()&lt;/strong&gt; function in your application, add a short &amp;quot;wait&amp;quot; before implementing the errata 89 workaround manually.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/330045?ContentTypeID=1</link><pubDate>Fri, 17 Sep 2021 12:46:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2231496-e9e4-4d40-af3e-d745a225c961</guid><dc:creator>Poorp</dc:creator><description>&lt;p&gt;Thanks for taking the time to look into this!&lt;/p&gt;
&lt;p&gt;I realized that I can trigger the same problem with the nrf52dk (PCA10040, v1.2.4 2019.19) so I created a minimal project to that replicates it. Hopefully it&amp;#39;ll make it easier for you to figure out.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve attached it below, and included pre-compiled hex files. Incase it only triggers with certain versions of the nrf connect sdk.&lt;br /&gt;I compiled it with &amp;quot;cmake -DBOARD=nrf52dk_nrf52832 -B./build_output &amp;amp;&amp;amp; make -j9 -C ./build_output&amp;quot;&lt;/p&gt;
&lt;p&gt;The below graph shows the problem on as measured with the nrf52dk&lt;br /&gt;Green is with is using i2c (with nothing physicall connected to dk) and an edge trigger&lt;br /&gt;Red is with using i2c (again nothing connected) and a level_low trigger&lt;/p&gt;
&lt;p&gt;Yellow is with the edge trigger and no i2c&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/graphmaximum.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/bug.zip"&gt;devzone.nordicsemi.com/.../bug.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/329915?ContentTypeID=1</link><pubDate>Fri, 17 Sep 2021 06:11:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ddad461-cb60-4701-92d7-b54780e7f3d1</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Thanks for specifying.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll need some more time to look into what might be causing this, as I don&amp;#39;t see why the combination of TWI and EDGE_FALLING interrupt would result in a higher current consumption than using just one of the two.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll get back to you on Monday when I&amp;#39;ve done some more digging on my end.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/329608?ContentTypeID=1</link><pubDate>Wed, 15 Sep 2021 12:12:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91037de4-aa94-4b12-91f6-f93ae707932b</guid><dc:creator>Poorp</dc:creator><description>&lt;p&gt;Hi&lt;br /&gt;&lt;br /&gt;What I meant is that the excess current consumption only happens if we set the interrupt to GPIO_INT_EDGE_FALLING _and_ read to or write to the i2c bus. &lt;br /&gt;&lt;br /&gt;Using any of the following uses a normal amount of current:&lt;br /&gt;* only I2c&lt;br /&gt;*only an interrupt on GPIO_INT_EDGE_FALLING&lt;/p&gt;
&lt;p&gt;* i2c and interrupt on GPIO_INT_LEVEL_LOW&lt;br /&gt;&lt;br /&gt;I can&amp;#39;t remember off the top of my head what the normal power consumption is, and it depends on if we run the i2c bus or not. But I believe around 20 microamps or so. Please let me know if exact numbers would help and I&amp;#39;ll get them for you.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Could using the i2c/twi cause the device to switch what event type it uses from a Port to IN_EVENT for GPIO_INT_EDGE_FALLING?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/329596?ContentTypeID=1</link><pubDate>Wed, 15 Sep 2021 11:51:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5e23fd8-94b4-4bdb-95c4-7a15a0297570</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;By &amp;quot;the problem&amp;quot; I assume you mean the excess current consumption you&amp;#39;re seeing &lt;strong&gt;only&lt;/strong&gt;&amp;nbsp;occurs when using the GPIO_INT_EDGE_FALLING instead of I.E. GPIO_INT_LEVEL_LOW, correct? What current does the device draw when the GPIO trigger is set to LEVEL_LOW instead for instance?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think this is due to the GPIOTE is using an IN event rather than a PORT event. An IN_EVENT will require the device to use the HF clock, explaining the increased current consumption.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/329275?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 15:01:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2c29057-3e64-4365-b41b-d52e5edc8b0e</guid><dc:creator>Poorp</dc:creator><description>&lt;p&gt;Edit: I was mistaken with my previous information, updated the post with the correct information&lt;br /&gt;&lt;br /&gt;We&amp;#39;ve managed to narrow down the problem further. But I&amp;#39;m not sure why we&amp;#39;re seeing the behavior we&amp;#39;re seeing,&lt;br /&gt;&lt;br /&gt;The problem only occurs if we configure i2c, write or read from it, AND setup a pin interrupt on one of the gpioe to trigger on an edge.&lt;/p&gt;
&lt;p&gt;That is if we set the trigger to GPIO_INT_LEVEL_LOW, instead of e.g GPIO_INT_EDGE_FALLING, the problem does not occur.&lt;br /&gt;I don&amp;#39;t believe that it is caused by interference triggering the interrupt, because I added a print statement to the example code interrupt (see &amp;quot;triggered&amp;quot; below) and that doesn&amp;#39;t get triggered except e.g when the button is pushed. &lt;br /&gt;&lt;br /&gt;What particular pin the interrupt is configured for doesn&amp;#39;t seem to matter, we&amp;#39;ve tried pin 25, 29 and 6 all with the same effect. Pin 25 is connected to a button, and 29 and 6 are not connected on our board.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void trigger_reset_polling(const struct device *dev, struct gpio_callback *cb,
		    uint32_t pins)
{
	LOG_INF(&amp;quot;triggered&amp;quot;);
}


void reset_init(void)
{
	reset_button_dev = device_get_binding(RESET_LABEL);
	__ASSERT(reset_button_dev != NULL, &amp;quot;error device not found&amp;quot;);

	int const conf_ret = gpio_pin_configure(reset_button_dev, RESET_PIN, GPIO_INPUT | RESET_FLAGS);
	__ASSERT(conf_ret == 0, &amp;quot;Failed to configure pin, error: %d&amp;quot;, conf_ret);

	int const inter_ret = gpio_pin_interrupt_configure(reset_button_dev,
					   RESET_PIN,
					   GPIO_INT_EDGE_FALLING);
	__ASSERT(inter_ret == 0, &amp;quot;Failed to configure interrupt&amp;quot;);

	gpio_init_callback(&amp;amp;reset_cb_data, trigger_reset_polling, BIT(RESET_PIN));
	gpio_add_callback(reset_button_dev, &amp;amp;reset_cb_data);
	LOG_DBG(&amp;quot;Set up button at %s pin %d\n&amp;quot;, RESET_LABEL, RESET_PIN);

	k_work_init(&amp;amp;detect_reset_work, detect_reset);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/329187?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 10:34:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b465a98-48ca-46fe-9d78-b4d9b3b166e0</guid><dc:creator>Poorp</dc:creator><description>&lt;p&gt;Hi&lt;br /&gt;&lt;br /&gt;Thanks for taking the time to look at this.&lt;br /&gt;&lt;br /&gt;The excess current consumption is about ~270microamps&lt;/p&gt;
&lt;p&gt;As you asked I have now checked and the above errata code is executed and returns true. It had/has no effect on the excess current.&lt;br /&gt;&lt;br /&gt;My understanding is that the i2c bus will use about ~200microamps when active. Could it be that it never goes in-active after having transmitted the data? If so what is the correct way to tell it to do so?&lt;br /&gt;&lt;br /&gt;Best Regards&lt;br /&gt;Poorp&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Excessive power usage when using i2c/twi</title><link>https://devzone.nordicsemi.com/thread/328797?ContentTypeID=1</link><pubDate>Thu, 09 Sep 2021 11:35:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22e42be5-632a-4fa1-9209-0ba4eefb24fd</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Can you specify just how large the excess current consumption you see is? If it&amp;#39;s ~400uA it does indeed seem like the erratum 89 is what&amp;#39;s causing this, but it should be implemented for nRF52832&amp;nbsp;projects in the nRFConnect SDK from&amp;nbsp;C:\...\&lt;strong&gt;NCS_FOLDER&lt;/strong&gt;\v&lt;strong&gt;x.x.x&lt;/strong&gt;\modules\hal\nordic\nrfx\mdk\nrf52_erratas.h. If it seems like this is it, please try implementing the fix as it is done in nrf52_erratas.h instead of how it&amp;#39;s described in the &lt;a href="https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/anomaly_832_89.html"&gt;Infocenter&lt;/a&gt;, as that&amp;#39;s the workaround how it should be used in the nRF5 SDK.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>