<?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>Rogue I2C read starting when I force Zephyr to shut down</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113219/rogue-i2c-read-starting-when-i-force-zephyr-to-shut-down</link><description>Hi, 
 I&amp;#39;m using SDK 2.1.0 for this project. 
 I found that when I shut down using the following: 
 
 pm_state_force ( 0u , &amp;amp;( struct pm_state_info){PM_STATE_SOFT_OFF, 0 , 0 }); // Force a hard off where the interrupt wakeup resets the processor 
 
 I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 22 Jul 2024 17:58:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113219/rogue-i2c-read-starting-when-i-force-zephyr-to-shut-down" /><item><title>RE: Rogue I2C read starting when I force Zephyr to shut down</title><link>https://devzone.nordicsemi.com/thread/495095?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2024 17:58:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64f6455e-d46d-4fe3-99fd-f58690a9ab07</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;I found it - I guess with my sequence of events I was ending up with the worker task that my pin ISR kicks off pending, and the sleeps I threw in assuming that any pending tasks would run wasn&amp;#39;t getting it done.&amp;nbsp; I added a call to k_work_cancel for that task and my unwanted I2C half-read is gone.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rogue I2C read starting when I force Zephyr to shut down</title><link>https://devzone.nordicsemi.com/thread/494901?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2024 20:26:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba595847-b352-4603-a2f8-7f619fb989f9</guid><dc:creator>Glen M</dc:creator><description>&lt;p&gt;I don&amp;#39;t think so. It&amp;#39;s a custom driver I made for this device but it appears to just use the i2c_nrfx_twi driver. My .dts file looks like this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;amp;i2c0 {&lt;br /&gt; compatible = &amp;quot;nordic,nrf-twi&amp;quot;;&lt;br /&gt; status = &amp;quot;okay&amp;quot;;&lt;br /&gt; pinctrl-0 = &amp;lt;&amp;amp;i2c0_default&amp;gt;;&lt;br /&gt; pinctrl-1 = &amp;lt;&amp;amp;i2c0_sleep&amp;gt;;&lt;br /&gt; pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;&lt;br /&gt; clock-frequency = &amp;lt;100000&amp;gt;;&lt;br /&gt; &lt;br /&gt; tm065049@2A {&lt;br /&gt; compatible = &amp;quot;nordic,tm065049&amp;quot;;&lt;br /&gt; int-gpios = &amp;lt;&amp;amp;gpio0 25 (GPIO_ACTIVE_LOW)&amp;gt;;&lt;br /&gt; reg = &amp;lt;0x2A&amp;gt;; &lt;br /&gt; }; &lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve found that this only happens when there&amp;#39;s been heavy traffic happening while I&amp;#39;m shutting down, but at this point I feel like I&amp;#39;ve tried everything to get it to shut off, including lots of k_sleep delays to let things finish.&lt;/p&gt;
&lt;p&gt;I even did my best to disable and uninitialize the I2C driver and turn the SDA and SCL lines back into GPIO so it can&amp;#39;t send anything, but my best attempt at code to do that apparently doesn&amp;#39;t work. I think I have the device definition for my &lt;span&gt;nrfx_twi_t&amp;nbsp; struct&amp;nbsp;&lt;/span&gt;wrong.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;// GDM I added this function because I found that when shutting down in board.c via pm_state_force, I was getting&lt;br /&gt;// a half a read coming out of the I2C port.&lt;br /&gt;static const struct device *const m_i2c_dev = DEVICE_DT_GET(DT_NODELABEL(i2c0));&lt;br /&gt;static const struct device *const gpio_dev = DEVICE_DT_GET(DT_NODELABEL(gpio0));&lt;/p&gt;
&lt;p&gt;void disableI2C(void)&lt;br /&gt;{&lt;br /&gt; const struct nrfx_twi_t *config = m_i2c_dev-&amp;gt;config;&lt;/p&gt;
&lt;p&gt;nrfx_twi_disable(config);&lt;br /&gt; nrfx_twi_uninit(config);&lt;/p&gt;
&lt;p&gt;// Reconfigure the I2C pins as inputs&lt;br /&gt; gpio_pin_configure(gpio_dev, 26, GPIO_INPUT);&lt;br /&gt; gpio_pin_configure(gpio_dev, 27, GPIO_INPUT);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Rogue I2C read starting when I force Zephyr to shut down</title><link>https://devzone.nordicsemi.com/thread/494895?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2024 20:07:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bb4e99a-a332-49b5-8606-903e11f2c110</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;Hello Glen,&lt;/p&gt;
&lt;p&gt;Are you using some specific I2C device driver from zephyr by chance?&lt;/p&gt;
&lt;p&gt;I wonder if it could be part of the shutdown procedure in the driver for this device.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>