<?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>52832 timer consumes a lot of power</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53425/52832-timer-consumes-a-lot-of-power</link><description>Hello 
 A project that recently made a sensor found that the timer consumes a lot of power. 
 I built a timer to collect sensor data in the timer handler. 
 
 Sensor only cost 10uA, but I got 4ma 5ms . 
 
 I understand that there is no time-consuming</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Oct 2019 01:14:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53425/52832-timer-consumes-a-lot-of-power" /><item><title>RE: 52832 timer consumes a lot of power</title><link>https://devzone.nordicsemi.com/thread/215810?ContentTypeID=1</link><pubDate>Mon, 21 Oct 2019 01:14:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3e5a736-15cf-4e7f-9671-f8812ee50999</guid><dc:creator>Август</dc:creator><description>&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 52832 timer consumes a lot of power</title><link>https://devzone.nordicsemi.com/thread/215784?ContentTypeID=1</link><pubDate>Sat, 19 Oct 2019 21:45:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc574a2c-2a46-40c4-a7fb-c521599cdd1b</guid><dc:creator>Patrick</dc:creator><description>&lt;p&gt;Would you happen to have a resource that explains event based programming in the context of a device driver using a peripheral such as TWI or SPI? The Nordic examples of using TWI/SPI with an event handler does not really do more than add a wait loop that may sleep while waiting on an event. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 52832 timer consumes a lot of power</title><link>https://devzone.nordicsemi.com/thread/215782?ContentTypeID=1</link><pubDate>Sat, 19 Oct 2019 19:17:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bff315b8-5e8f-4a18-bc90-d428997b0cc2</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;The line&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;while (m_transfer_done==0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;alone consumes the majority of your 4mA current consumtion over 5ms, because the MCU core will stay active the whole time doing pretty much nothing.&lt;/p&gt;
&lt;p&gt;However,&lt;em&gt; removing&lt;/em&gt; this line requires a code redesign that I would not consider trivial or beginner friendly, but the experience could teach you event-based programming (or properly using event handlers).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 52832 timer consumes a lot of power</title><link>https://devzone.nordicsemi.com/thread/215774?ContentTypeID=1</link><pubDate>Sat, 19 Oct 2019 09:19:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68c04f9a-6cc2-400a-a576-aac55e32af22</guid><dc:creator>Август</dc:creator><description>&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;I have used&amp;nbsp;&lt;span&gt;the I&amp;sup2;C event handler but it also need to wait ack&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1571476279226v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Yes it support SPI.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I tried to add a 5ms delay to the timer handler. The result is the same. It seems that the iic read and write operation is delayed by 5ms here.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;task_read_kx022() is&amp;nbsp;reading triaxial acceleration data with iic.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 52832 timer consumes a lot of power</title><link>https://devzone.nordicsemi.com/thread/215773?ContentTypeID=1</link><pubDate>Sat, 19 Oct 2019 09:03:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b55c7b8d-82e0-458f-ab6c-d32539e9ae22</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Pretty much impossible to recommend anything since we have zero clue what task_read_kx022() &lt;em&gt;actually&lt;/em&gt; does.&lt;/p&gt;
&lt;p&gt;By the looks of your scope output it busy-waits for the I&amp;sup2;C transaction (or transactions ?) to finish - you could change that to use the I&amp;sup2;C event handler, but this obviously requires non-trivial changes to the source code.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Note: Does this sensor support SPI? That could transfer data one order of magnitude faster...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>