<?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 Current Consumption</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59283/twi-current-consumption</link><description>Dear All , 
 I am a little stumped.... Basically first i was working with the beacon app on sdk 12 on the 51822 chip. Now I have moved to the 52382 chip. 
 I modified the app to run with my requirements. I added a timer to fire at every 5 seconds to check</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Mar 2020 14:25:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59283/twi-current-consumption" /><item><title>RE: TWI Current Consumption</title><link>https://devzone.nordicsemi.com/thread/241406?ContentTypeID=1</link><pubDate>Tue, 24 Mar 2020 14:25:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0edea98e-b31f-4fd5-9be7-e8bc835cbf15</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;So I assume you have a &lt;span&gt;twi_handler() that will set&amp;nbsp;m_xfer_done. And I assume you clear&amp;nbsp;m_xfer_done before calling&amp;nbsp;nrf_drv_twi_tx() or&amp;nbsp;nrf_drv_twi_rx(). By doing this you can have a while loop after&amp;nbsp;nrf_drv_twi_tx() and&amp;nbsp;nrf_drv_twi_rx() that wait for&amp;nbsp;m_xfer_done is set.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I assume you are calling all nrf_drv_twi* calls from main or an interrupt context that is lower priority than the twi interrupt, else the&amp;nbsp;twi_handler() will not be able to execute.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If the TWI transfers are slower than you expect, then you should check out the actual TWI transfer using a logic analyzer (monitor the SCL and SDA pins). Have in mind though that even if the sensor is fast to sample, the serial interface is still limited to the clock speed of TWI, which may be &amp;lt;400kHz or lower. So 10ms may not be far off expected depending on the number of bytes and possible wait states.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Current Consumption</title><link>https://devzone.nordicsemi.com/thread/241340?ContentTypeID=1</link><pubDate>Tue, 24 Mar 2020 11:07:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ce3d540-4e22-4075-a93b-5c1822c090e9</guid><dc:creator>Nadeem</dc:creator><description>&lt;p&gt;Hey Kenneth ,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.. Can you help me on how to send consecutive reads and writes.. I believe your right in the fact that its because of the CPU running and not being able to sleep.&lt;/p&gt;
&lt;p&gt;The issue is if i remove the Delays i always get NRF_busy error. although i have&amp;nbsp;&lt;span&gt;while (m_xfer_done == false);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I tried to make a function called waitms() with a single shot timer, but the timer handler is not being called. It works fine when i dont send any TWI reads or writes.. but when i send some read and writes the handler is not called..&lt;/p&gt;
&lt;p&gt;My idea was :-&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;void writeRegister(uint8_t RegisterAddr, uint8_t Data)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; //while (m_xfer_done == false);&lt;br /&gt; uint8_t reg[2] = {RegisterAddr,Data};&lt;br /&gt; err_code = nrf_drv_twi_tx(&amp;amp;m_twi, MP121_ADDR, reg, 2, false); &lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; while (m_xfer_done == false);&lt;br /&gt;watMs(10);&lt;/p&gt;
&lt;p&gt;&lt;span&gt;while (WaitFlage== false);&lt;/span&gt;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;But this doesnt work as the Waitflag is not being set by the single shot timer handler. Maybe my idea is not feasible in first place.. if not can you advise how to avoid wasted cpu cycles and put the cpu in sleep mode..&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Secondly is the NRF_busy related to the Sensor chip or something else? I initialy thought the sensor needed time to process the request but when i saw the data sheet of the mpr121 it is pretty fast .. only needs 1.5 us to respond , while i am needing atleast 10 ms. to avoid getting the nrf busy error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Current Consumption</title><link>https://devzone.nordicsemi.com/thread/241055?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 09:38:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:937fd403-59a7-4efe-b5ff-2c29fc1f4565</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;You may get some pointers here in general:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/optimizing-power-on-nrf52-designs"&gt;https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/optimizing-power-on-nrf52-designs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If the CPU is running (not in sleep) it will draw a few mA, in sleep the chip should draw only a few uA. If it is drawing tens of uA you should check for floating GPIO&amp;#39;s or if it may be due to a known errata that require workaround:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/err_832_new.html"&gt;https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/err_832_new.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Current Consumption</title><link>https://devzone.nordicsemi.com/thread/240713?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2020 16:43:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4cfb881-d154-4bd7-b274-2f9019f3c085</guid><dc:creator>Nadeem</dc:creator><description>&lt;p&gt;I have a handlre whicb just stores the return data to a global variable.&amp;nbsp; What concerns me is two things.. that how is it possible when running the twi can consume so much data.. also when sd power of.. my system still consumes 60 ua...&lt;/p&gt;
&lt;p&gt;I am already using power manage run as shown in idle state handle function...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Current Consumption</title><link>https://devzone.nordicsemi.com/thread/240691?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2020 15:17:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12d25511-a97c-438e-a6ea-44dda01cd01e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I notice you are writing:&amp;nbsp;&lt;span&gt;nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_lm75b_config, twi_handler, NULL);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But I can&amp;#39;t see your twi_handler()?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Have you tried:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_lm75b_config, NULL, NULL);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you don&amp;#39;t have any debugging, you can use&amp;nbsp;nrf_pwr_mgmt_run() directly. What is the implementation of&amp;nbsp;nrf_pwr_mgmt_run()?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI Current Consumption</title><link>https://devzone.nordicsemi.com/thread/240615?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2020 11:27:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32c0c4bb-8cb1-4403-bda0-5f8e3669fe2b</guid><dc:creator>Nadeem</dc:creator><description>&lt;p&gt;Read and write functions:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;void writeRegister(uint8_t RegisterAddr, uint8_t Data)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; uint8_t reg[2] = {RegisterAddr,Data};&lt;br /&gt; err_code = nrf_drv_twi_tx(&amp;amp;m_twi, MP121_ADDR, reg, 2, false); &lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; while (m_xfer_done == false);&lt;br /&gt; nrf_delay_ms(10);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;void readRegister8(uint8_t RegisterAddr)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; uint8_t reg[2];&lt;br /&gt; reg[0] =RegisterAddr;&lt;br /&gt; nrf_delay_ms(20);&lt;br /&gt; err_code = nrf_drv_twi_tx(&amp;amp;m_twi, MP121_ADDR, reg, 1, true);&lt;br /&gt; nrf_delay_ms(100);&lt;br /&gt; if (NRF_SUCCESS == err_code)&lt;br /&gt; err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MP121_ADDR, &amp;amp;m_sample, 1);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; nrf_delay_ms(100);&lt;br /&gt;}&lt;br /&gt;void readRegister16(uint8_t RegisterAddr)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; uint8_t reg[2];&lt;br /&gt; reg[0] =RegisterAddr;&lt;br /&gt; nrf_delay_ms(100);&lt;br /&gt; err_code = nrf_drv_twi_tx(&amp;amp;m_twi, MP121_ADDR, reg, 1, true);&lt;br /&gt; nrf_delay_ms(100);&lt;br /&gt; if (NRF_SUCCESS == err_code)&lt;br /&gt; err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MP121_ADDR, &amp;amp;m_sample, 2);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; nrf_delay_ms(100);&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>