<?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 in Low Power...</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9926/twi-in-low-power</link><description>Hey guys, 
 Trying to use TWI in the lowest power way possible, non-blocking. Is this the right way to do it? When I run this, I get the callback event handler to execute once, and once only -- seemingly stuck in WFE() or sd_app_evt_wait() , not waking</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Oct 2015 09:49:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9926/twi-in-low-power" /><item><title>RE: TWI in Low Power...</title><link>https://devzone.nordicsemi.com/thread/36830?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2015 09:49:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55fdbe25-a036-4d54-9cb2-85aa905c9923</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Maybe you are getting the NACK event I have mentioned in the comment above. You will get the event right after your nRF5x has transmitted the address and not gotten any response. You won&amp;#39;t get any valid data either.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI in Low Power...</title><link>https://devzone.nordicsemi.com/thread/36828?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2015 09:44:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da90f4ad-459d-4854-9402-36e7909be2ee</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Error 2 is&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TWI_ERROR_ADDRESS_NACK = TWI_ERRORSRC_ANACK_Msk,    /**&amp;lt; NACK received after sending the address. */
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;as defined in nrf_twi.h&lt;/p&gt;
&lt;p&gt;So I guess you don&amp;#39;t get any response from your external device?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI in Low Power...</title><link>https://devzone.nordicsemi.com/thread/36829?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 19:24:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b05dfebe-02eb-4384-ba0e-0973ef3e215b</guid><dc:creator>Brian</dc:creator><description>&lt;p&gt;Yeah... I just put a flag around the call to nrf_drv_twi_rx and that worked.&lt;/p&gt;
&lt;p&gt;if(RX_ready) nrf_drv_twi_rx..., then RX_ready=FALSE&lt;/p&gt;
&lt;p&gt;Then set RX evt handler, I set RX_ready to TRUE.&lt;/p&gt;
&lt;p&gt;Curious why we exit WFE so quickly without valid TWI data though.  I don&amp;#39;t know of anything else going on that would interrupt things.   Has this TWI driver been optimized for power at all?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI in Low Power...</title><link>https://devzone.nordicsemi.com/thread/36827?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 19:15:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aaf83742-3e29-41eb-a8e4-2dd3947dad34</guid><dc:creator>Brian</dc:creator><description>&lt;p&gt;Thanks.  You&amp;#39;re correct.  The handler is getting called as fast as possible... it is not sleeping.
Inserted this into the handler.
SEGGER_RTT_printf(0, &amp;quot;\n\nTWI ERROR: %d &amp;quot;, p_evt-&amp;gt;error_src);
The results: TWI ERROR: 2
But not sure that&amp;#39;s helpful.   NRF_DRV_TWI_ERROR is defined as 2.
So what is this telling us?   Seems like we&amp;#39;re breaking out of WFE before we actually get real data back successfully, and then immediately try to do another i2c transaction before the previous one completes.  Could that be the case?
Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI in Low Power...</title><link>https://devzone.nordicsemi.com/thread/36826?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 09:48:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:346c6bee-7e68-472d-963e-2fb9d5fa80ae</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi. Are you sure the handler is only called once? You might get a lot of other events that is not detected by your if-statement.&lt;/p&gt;
&lt;p&gt;Also, I don&amp;#39;t know your application but, but a lot of TWI sensors, memory chips, etc, need you to do a TWI TX operation first to tell which address in the device to read from. With nrf_drv_twi_&lt;strong&gt;rx&lt;/strong&gt;() you just tell a device on a specific address &amp;quot;give me data!&amp;quot;. You don&amp;#39;t tell the device what data you want and this might cause troubles on your TWI bus. Try to add&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[...]
else
{
   SEGGER_RTT_printf(0, &amp;quot;\n\nTWI ERROR: %d &amp;quot;, p_evt-&amp;gt;error_src);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or something to listen for other TWI events.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>