<?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>power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50368/power-optimal-twi-tx-rx</link><description>Hi - I am wondering what is the power optimal way to read/write with the TWI module. I do a tx and rx with the TWI interface. I have something like this, from the examples to read data from a i2c supported device: 
 
 
 I am not sure if this is the most</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Aug 2019 10:29:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50368/power-optimal-twi-tx-rx" /><item><title>RE: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/203258?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 10:29:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acf05861-3860-401c-ab38-9ed9870fb49d</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;What SDK version are you using? If you&amp;#39;re using a very old one (before SDK v.14.x) I&amp;#39;d suggest you update it due to implementations of various bug fixes, as well as more and updated example projects.&lt;/p&gt;
&lt;p&gt;An address/data nack should not cause any issues in our TWI examples, you&amp;#39;ll just have to resend the transfer. You can take a look at this thread, where a power optimization method is proposed by using the app_timer.&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: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/203170?ContentTypeID=1</link><pubDate>Thu, 08 Aug 2019 21:23:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca295874-0eae-4594-9761-67e1b5f5f55c</guid><dc:creator>rookie</dc:creator><description>&lt;p&gt;I am referring to twi _sensor where a twi_handler callback is used. The example there has a while wait loop until &amp;quot;m_xfer_done&amp;quot; is set . So it becomes a busy loop. Is there a better way to implement it without busy-looping? Also, what would happen if I get an address nack or data nack.&amp;nbsp; Things start getting messier once I start having a flag for each state(like rx/tx /addr nack/ data nack).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think the SDK I am using doesn&amp;#39;t yet have the twi manager.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/202770?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2019 09:04:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa66786e-44d1-4df9-8409-def815709823</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;What example is your application based on? Do you have an event handler that the callback goes to after you&amp;#39;ve called a TWI event? If you do have a callback, you can just wait for that using the idle_state_handle() function, similar to what&amp;#39;s done in many of our examples. If this callback is in another file than your main.c file, you can forward it to main.c in order to make it easier.&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: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/202488?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2019 17:49:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8409d12e-abb0-4dd9-b5c4-a1ae2dc62844</guid><dc:creator>rookie</dc:creator><description>&lt;p&gt;Thanks awneil.&lt;/p&gt;
&lt;p&gt;I have expanded on my question in my reply to simonr. My example is simple where I want to read a register. So What would be my options instead of waiting(using delay) for the twi handler to return an event to indicate a successful read.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/202487?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2019 17:30:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:168e2ba8-0a0e-4162-9e5c-7b5ddecde9f9</guid><dc:creator>rookie</dc:creator><description>&lt;p&gt;I know there is an idle state handler in most examples.&amp;nbsp;May I frame my question slightly differently.&lt;/p&gt;
&lt;p&gt;If I understand correctly the&amp;nbsp;nrf_drv_twi_tx/nrf_drv_twi_rx calls are non-blocking since a twi handler gets a callback when a tx or rx event is complete. So let&amp;#39;s say when I want to read a register, so we do a tx and then an rx. Now until I receive the rx event in the handler I haven&amp;#39;t actually received the value correctly. If I want to write an API to read a register where I pass a value that will be filled with the register value, I will have to jump to the twi handler and then back or just simply waitusing a delay which is not efficient. So my question would be do you have any suggestion to write this effectively?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/201245?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 12:30:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e46ceba-03e5-4e0e-988f-0b43c4c6b980</guid><dc:creator>awneil</dc:creator><description>[quote userid="72833" url="~/f/nordic-q-a/50368/power-optimal-twi-tx-rx/201061"]Not sure what other factors may be involved? [/quote]
&lt;p&gt;Common things include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You might need some things to stay active/responsive while you sleep;&lt;/li&gt;
&lt;li&gt;The more you shut down, the more you have to wake up again to get back into &amp;quot;normal operation&amp;quot;;&lt;/li&gt;
&lt;li&gt;The deeper you sleep, the longer it takes to wake again;&lt;/li&gt;
&lt;li&gt;Deeper sleep options often have more limited wakeup options;&lt;/li&gt;
&lt;li&gt;etc, etc, ...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As &lt;a href="https://devzone.nordicsemi.com/members/simonr"&gt;Simonr&lt;/a&gt; says, many (most?) of the SDK examples illustrate sleeping while waiting for events ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/201238?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 12:19:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a298ff91-ee43-476e-95bc-489acfee8542</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Yes, you can use _WFE(). But we recommend using the idle_state_handle() function which flushes the NRF_LOG and runs nrf_pwr_mgmt_run(). Please see the&amp;nbsp;&lt;strong&gt;...\nRF5_SDK_15.0.0_a53641a\examples\ble_central\ble_app_blinky_c&lt;/strong&gt; example for reference.&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: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/201061?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2019 17:21:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3035f362-51bb-47e3-a4d9-260398da66cc</guid><dc:creator>rookie</dc:creator><description>&lt;p&gt;Yes, I mean minimal. Not sure what other factors may be involved? In this case it is really about minimizing current draw.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I agree busy loop is not optimal. How do I let it sleep until I get an event, say a NRF_DRV_TWI_XFER_TX or NRF_DRV_TWI_XFER_RX? Do I use _WFE() ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: power optimal twi tx/rx</title><link>https://devzone.nordicsemi.com/thread/201057?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2019 16:57:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e02f08d5-9c74-4a8c-8e27-8c300717da96</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;By &amp;quot;optimal&amp;quot; do you really mean &amp;quot;minimum&amp;quot; - or do you also have other factors to consider ?&lt;/p&gt;
&lt;p&gt;Just spinning in a busy loop is never going to be low-power - as it requires the CPU to be running at full speed, without letting it do anything useful.&lt;/p&gt;
&lt;p&gt;Could you not let it sleep, and wake on the &amp;quot;finished&amp;quot; event?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>