<?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>Current consumption NRF52</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19326/current-consumption-nrf52</link><description>I&amp;#39;m struggling with current consumption. I need my device to completely sleep and leave only the RTC on when the ext power is off (run on battery). After making sure my RTC was actually working, I ran the following code: 
 void run_ClockMode()
{
	uint32_t</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Feb 2017 08:47:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19326/current-consumption-nrf52" /><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74957?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 08:47:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b318844-6894-4848-9f0a-6b8dccd3b6e5</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;When LD5 is flashing fast, I think it means that the JLink has not initialized the driver yet. I&amp;#39;ve seen this problem in linux, where I sometimes have to reset the kit in order for it to reinitialize the driver, if not it will just continue flashing. Can&amp;#39;t remember I&amp;#39;ve seen this on windows though, but you can try to install the latest driver from here: &lt;a href="https://www.segger.com/downloads/jlink"&gt;J-Link Software and Documentation Pack&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74959?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 17:15:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bc91b5e-569b-41ff-8fd0-cd1b1a2ac0b3</guid><dc:creator>Felipe Ribas</dc:creator><description>&lt;p&gt;Sorry about that, I do have the MainRTC definition outside the functions. And the buffer and other stuff I literally copied the code from inside APP_TIMER_INIT macro anyways. I found the problem... I have no clue why but after I program, I turn on the board without the USB cable to measure the current but the LED called LD5 keeps flashing nonstop. I&amp;#39;m using external power supply set to 3.3V and I opened the SB9 to measure the current. But after just powering off and on again the LD5 goes off then I can sense 2.0uA. Funny that happened sometimes only... it seems only in the first time I power on the board right after programming it happens. Then all the other times it powers on normally without LD5 flashing and already measuring 2uA. I don&amp;#39;t know if I was clear enough, but any tips about that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74958?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 16:01:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a67ffe2-fbe2-41fa-aedb-2d1b271ef243</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;I tested your code and seems like you forgot the APP_TIMER_DEF macro to initialize the MainRTC variable. Also you should use the APP_TIMER_INIT macro so the buffer size is initialized correctly. something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define PRESCALER 4095
#define TIMER_DELAY 1000
void run_ClockMode()
{
    nrf_drv_clock_init();
    nrf_drv_clock_lfclk_request(NULL);
    while (!nrf_drv_clock_lfclk_is_running());
    APP_TIMER_INIT(PRESCALER, 1, NULL);
    APP_TIMER_DEF(MainRTC);
    app_timer_create(&amp;amp;MainRTC, APP_TIMER_MODE_REPEATED, MainRTC_handler);
    app_timer_start(MainRTC, APP_TIMER_TICKS(TIMER_DELAY, PRESCALER), NULL);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I measured on this code and it gave me about 2uA in average between the timer interrupts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74956?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 13:19:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:332fd79c-0240-49a8-b695-2707d9e33c39</guid><dc:creator>Felipe Ribas</dc:creator><description>&lt;p&gt;Ok, I tested with only the WFE inside the loop. Now it dropped the current consumption. However, I still get around 12 uA. The code is exaclty like the first code on my original post but with WFE inside an infinite loop. Am I still missing to achieve &amp;quot;System ON, no RAM retention + RTC + LFRC = 1.2uA + 0.1uA + 0.6uA = 1.9uA&amp;quot;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74955?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 12:39:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68b57fb6-acb2-41f8-87f7-e2144f00efae</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;The difference is discussed in this post: &lt;a href="https://devzone.nordicsemi.com/question/1555/how-do-you-put-the-nrf51822-chip-to-sleep/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In general, it is best to only use one WFE in the loop to avoid race conditions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74953?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 11:47:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aafd4aaf-97fd-4a3e-a785-a6fba5722790</guid><dc:creator>Felipe Ribas</dc:creator><description>&lt;p&gt;Very nice. I will test it right now and come back with the answer. Meanwhile, is there any practical difference between using only WFE or WFE;SEV;WFE in the loop?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74954?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 11:30:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82a1a25e-fdd0-4564-a23e-dc7c516afbec</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;You need to put the &lt;code&gt;__WFE()&lt;/code&gt; inside the loop. Then it will wait for an event and return to the &lt;code&gt;__WFE()&lt;/code&gt; in the loop after the event. The &lt;code&gt;for(;;){}&lt;/code&gt; will keep the CPU running and consume about 4-5mA after it returns from the event. So &lt;code&gt;for(;;){__WFE;}&lt;/code&gt; is correct. Then it will return to the IDLE state every time it returns from an event.&lt;/p&gt;
&lt;p&gt;You need to calibrate if you want to get a higher accuracy, but it&amp;#39;s not mandatory.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74952?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 11:10:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f04e37a-781e-4575-989a-c4da36b6f9ab</guid><dc:creator>Felipe Ribas</dc:creator><description>&lt;p&gt;I am using the DK at the moment but I would like to use the internal RC clock anyways. Should I calibrate or something like this? And yes, I simplified a little bit the main function but the only difference is the endless loop after. I will edit now so you can see. Do you reckon it is just wasting energy on this infinite loop? I thought the __WFE() function was gonna block (sleep) until receive an event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Current consumption NRF52</title><link>https://devzone.nordicsemi.com/thread/74951?ContentTypeID=1</link><pubDate>Thu, 02 Feb 2017 09:55:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b4d24e1-f1a2-4ae8-979b-5f6ffb636ef9</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Seems like you are missing the main loop in your code. You main function should look like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
    run_ClockMode();
    while(true){
         __WFE();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Without the main loop the CPU will continue into unknown territory.&lt;/p&gt;
&lt;p&gt;If the above was just an error when posting the code here on the forum, one other thing I can think of is that the lfclk_request function requests the external LF clock and that you don&amp;#39;t have an external clock (crystal) on your board. If you are using the DK this shouldn&amp;#39;t be a problem though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>