<?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>TWI Module problems</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83270/twi-module-problems</link><description>Hi there I am facing a strange issue nowadays after working continuously for two weeks + with the TWI module. I started off the with twi_sensor example in non blocking but &amp;quot;polling&amp;quot; mode. 
 By polling mode I mean the xfer flag was continuously being read</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 07 Jan 2022 16:49:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83270/twi-module-problems" /><item><title>RE: TWI Module problems</title><link>https://devzone.nordicsemi.com/thread/346749?ContentTypeID=1</link><pubDate>Fri, 07 Jan 2022 16:49:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e8c64fc-3529-4b08-b2b2-f682d66ccb96</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Hi Muhammad, sorry for the delay.&lt;/p&gt;
&lt;p&gt;You could try disabling compiler optimizations. This would help narrow down the issue.&lt;/p&gt;
&lt;p&gt;Also check if &amp;quot;status_i2c&amp;quot; is declared as volatile. It is often related to volatile if one experiences that it works i debug but not in release mode.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module problems</title><link>https://devzone.nordicsemi.com/thread/345904?ContentTypeID=1</link><pubDate>Tue, 04 Jan 2022 12:45:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51d30a92-1f1f-4cb3-9e63-c3eef30664e4</guid><dc:creator>helsing</dc:creator><description>&lt;p&gt;Thanks Muhammad and Hugh for the question and suggested solution.&lt;/p&gt;
&lt;p&gt;I will be taking a look at this and you will hear back from me tomorrow.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module problems</title><link>https://devzone.nordicsemi.com/thread/345718?ContentTypeID=1</link><pubDate>Mon, 03 Jan 2022 15:12:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5b73f6c-e538-4936-b8a8-996532e27adb</guid><dc:creator>AliMahmood123</dc:creator><description>&lt;p&gt;I have also tried to add a whopping 10 second delay write after my write call, but it doesnt seem to work on Release mode. On debug mode like I said any form of delay does work&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module problems</title><link>https://devzone.nordicsemi.com/thread/345702?ContentTypeID=1</link><pubDate>Mon, 03 Jan 2022 14:28:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8345d58-cf4a-42f0-ab6c-8330755feef8</guid><dc:creator>AliMahmood123</dc:creator><description>&lt;p&gt;Hi there&lt;br /&gt;Thanks for the prompt reply. I thought so too that the EEPROM needed time and the branched function call did the trick&lt;br /&gt;I also add an nrf_delay_ms between the read write&lt;br /&gt;The code is simple&lt;br /&gt;&lt;br /&gt;status_i2c = i2c_get_status(&amp;amp;eeprom);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(status_i2c == i2c_idle)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status_i2c = write_api(&amp;amp;eeprom);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(status_i2c == pending)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status_i2c = i2c_get_status(&amp;amp;eeprom);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_delay_ms(2000);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; memset(myArr_rx,0,200);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status_i2c = read_api(&amp;amp;eeprom, &amp;amp;transfer_read);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(status_i2c == pending)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; status_i2c = i2c_get_status(&amp;amp;eeprom);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_LOG_INFO(&amp;quot;Get Status Failure&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;But despite of the delay, the code does not work in Release mode. I found the fix for eeprom write cycle problem, but why does a two second delay that completely halts the processor, is not enough for a transaction?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Module problems</title><link>https://devzone.nordicsemi.com/thread/345554?ContentTypeID=1</link><pubDate>Sun, 02 Jan 2022 20:35:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:988a1d8e-fee5-4b45-b8e7-57f4864cc00e</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;I suspect you are looking in the wrong place. The TWI write is behaving (probably) exactly as you wish/expect, but you may be overlooking something else. Write to an EEPROM via TWI/I2C takes a long time, typically 5mSecs. The &amp;quot;write&amp;quot; command completes immediately, but the write command only starts the internal memory write and that does not complete until (say) 5mSecs later so another write will fail if started before that time is up.&lt;/p&gt;
&lt;p&gt;Fix this by doing a status read of the EEPROM to check when the write has completed, or just wait for the worst-case write time.&lt;/p&gt;
&lt;p&gt;Why does it work in debug? &amp;#39;cos debug mode is slow and typically slow enough to allow the write to complete, although that may be flakey.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>