<?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>High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35534/high-current-consumption-on-nrf52-dk</link><description>Hi, 
 I have a beacon code for nrf51 that I wanted to port to nrf52. It uses app_timer, gpiote and adc. The power consumption in idle is ~30uA. Now I wanted to port this code to nrf52 but have problems with current consumption. What I see is that current</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Jun 2018 17:39:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35534/high-current-consumption-on-nrf52-dk" /><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/137968?ContentTypeID=1</link><pubDate>Wed, 27 Jun 2018 17:39:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4dbe351-8c56-4662-a64a-45f48b045514</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;So it turns out that my measuring setup which was valid for nrf51 is not for nrf52. Doing measurment with ampere meter as described in guide showed values which are more accurate. Thanks Havard !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/137817?ContentTypeID=1</link><pubDate>Wed, 27 Jun 2018 08:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2d2cdda-97f8-4b88-955d-2f55223deb5f</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;I dont see any aliasing. I will try different measuring methods and come back with results. It is quite possible that the way I measured current on nrf51 is not valid for nrf52.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/137811?ContentTypeID=1</link><pubDate>Wed, 27 Jun 2018 08:00:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0704578-3113-4a21-8465-46c74bda79b0</guid><dc:creator>H&amp;#229;vard</dc:creator><description>&lt;p&gt;I have never tried the gecko simplicity studio energy profiler, but have you had a look at this guide?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/tutorials/b/hardware-and-layout/posts/current-measurement-guide-introduction"&gt;https://devzone.nordicsemi.com/tutorials/b/hardware-and-layout/posts/current-measurement-guide-introduction&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Could it be you are seeing aliasing in the sampling?&lt;/p&gt;
&lt;p&gt;excerpt:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The nRF52 power supply uses auto-controlled refresh modes to maximize efficiency. What this basically means is that a capacitor is recharged regularly to provide power to the chip. The recharge off the capacitor happens during a very short time interval, and results in a high frequency peak in current. This peak is measured to be about 10 - 15 us long. In order to get the correct average current during these peaks, a sampling frequency corresponding to half the peak length is required. This results in a minimum frequency of 200k samples per second (1 sample every 5 us).&lt;/p&gt;
&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/137806?ContentTypeID=1</link><pubDate>Wed, 27 Jun 2018 07:40:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fb45516-03df-493e-ac32-940a4cfd5d02</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;I am using nrf52 dk. I tried 2 different ones - both 200uA. On the segger there is note about version - one was 1.1.1 and second was 1.2.1 - these are production version not an engineering samples ? I dont have anything connected to dk.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;About my measurment setup - it works well, with nrf51 I am able to measure current around 20uA.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/137791?ContentTypeID=1</link><pubDate>Wed, 27 Jun 2018 06:57:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51cdc0ea-a1d8-4be0-9a29-3eb2147ac9ea</guid><dc:creator>H&amp;#229;vard</dc:creator><description>&lt;p&gt;Hello, it should not be possible to draw that much current in system off, unless the chip or DK is faulty.&lt;/p&gt;
&lt;p&gt;Are you using a DK, or are you on a custom PCB? Could there be some external component drawing power?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/137371?ContentTypeID=1</link><pubDate>Mon, 25 Jun 2018 06:46:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:108cd4d8-bdca-4ee5-804b-955b5fc1e05b</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;I tired your code with systemOff and the result of consumption is around 200uA. Why would be hfclk running if I did not use it ? Any other ideas what can be wrong ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/136867?ContentTypeID=1</link><pubDate>Wed, 20 Jun 2018 08:54:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7867739-ac4e-40af-9209-97a5ff006095</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;I am using SDK 12.3. I will try to flash with SDK 14.2 example today. Also note that I had softdevice in my application, even though it was not enabled I think it may have impact on consumption.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/136862?ContentTypeID=1</link><pubDate>Wed, 20 Jun 2018 08:32:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a138965-5f65-4bcc-b883-969e2ab8df17</guid><dc:creator>H&amp;#229;vard</dc:creator><description>&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;font-size:10pt;"&gt;Ok, I will stay tuned for when you find time to try system off.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;font-size:10pt;"&gt;In the meantime, I tried the beacon example in SDK 14.2&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;font-size:10pt;"&gt;I removed all code from the main except __WFE(); loop like you described, and the power consumption was around 1,3&lt;span style="text-align:left;color:#474747;text-transform:none;text-indent:0px;letter-spacing:normal;font-style:normal;font-weight:400;white-space:normal;float:none;"&gt;µA as expected.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/136705?ContentTypeID=1</link><pubDate>Tue, 19 Jun 2018 09:39:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9569d5d6-a94f-4c3a-94d9-68de579be2dc</guid><dc:creator>Michal</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;ble_advdata.h&amp;quot;
#include &amp;quot;nordic_common.h&amp;quot;
#include &amp;quot;softdevice_handler.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_drv_gpiote.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf_drv_saadc.h&amp;quot;
#include &amp;quot;nrf52.h&amp;quot;

#define BAT_MEASURE_PERIOD_MINUTES      2
#define BAT_ANALOG_INPUT                NRF_SAADC_INPUT_AIN0
#define ADC_MEASURE_PERIOD_MINUTES      20
#define ADC_ANALOG_INPUT                NRF_SAADC_INPUT_AIN1
#define ADV_PERIOD_MS                   5000                              // advertising period
#define WAKE_GPIO                       13                                // wake up gpio
#define ADV_INTERVAL_MS                 1000                              // advertising interval
#define TX_POWER_LEVEL                  (-4)                                // tx power level
#define DEVICE_NAME                     &amp;quot;XYZ&amp;quot;                               // device name
#define APP_MAJOR_VALUE                 0x01, 0x02                        /**&amp;lt; Major value used to identify Beacons. */
#define APP_MINOR_VALUE                 0x03, 0x04                        /**&amp;lt; Minor value used to identify Beacons. */
#define VBAT_MAX_IN_MV                  3000

#define CENTRAL_LINK_COUNT              0                                 /**&amp;lt; Number of central links used by the application. When changing this number remember to adjust the RAM settings*/
#define PERIPHERAL_LINK_COUNT           0                                 /**&amp;lt; Number of peripheral links used by the application. When changing this number remember to adjust the RAM settings*/

#define IS_SRVC_CHANGED_CHARACT_PRESENT 0                                 /**&amp;lt; Include or not the service_changed characteristic. if not enabled, the server&amp;#39;s database cannot be changed for the lifetime of the device*/

#define APP_CFG_NON_CONN_ADV_TIMEOUT    0                                 /**&amp;lt; Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */
#define NON_CONNECTABLE_ADV_INTERVAL    MSEC_TO_UNITS(ADV_INTERVAL_MS, UNIT_0_625_MS) 
                                                                          /**&amp;lt; The advertising interval for non-connectable advertisement (100 ms). This value can vary between 100ms to 10.24s). */

#define APP_BEACON_INFO_LENGTH          0x17                              /**&amp;lt; Total length of information advertised by the Beacon. */
#define APP_ADV_DATA_LENGTH             0x15                              /**&amp;lt; Length of manufacturer specific data in the advertisement. */
#define APP_DEVICE_TYPE                 0x02                              /**&amp;lt; 0x02 refers to Beacon. */
#define APP_MEASURED_RSSI               0xC3                              /**&amp;lt; The Beacon&amp;#39;s measured RSSI at 1 meter distance in dBm. */
#define APP_COMPANY_IDENTIFIER          0x0059                            /**&amp;lt; Company identifier for Nordic Semiconductor ASA. as per www.bluetooth.org. */

#define APP_BEACON_UUID                 0x01, 0x12, 0x23, 0x34, \
                                        0x45, 0x56, 0x67, 0x78, \
                                        0x89, 0x9a, 0xab, 0xbc, \
                                        0xcd, 0xde, 0xef, 0xf0            /**&amp;lt; Proprietary UUID for Beacon. */

#define DEAD_BEEF                       0xDEADBEEF                        /**&amp;lt; Value used as error code on stack dump, can be used to identify stack location on stack unwind. */

#define APP_TIMER_PRESCALER             15                                /**&amp;lt; Value of the RTC1 PRESCALER register. */
#define APP_TIMER_OP_QUEUE_SIZE         4                                 /**&amp;lt; Size of timer operation queues. */

// #define USE_UICR_FOR_MAJ_MIN_VALUES

// #if defined(USE_UICR_FOR_MAJ_MIN_VALUES)
#define MAJ_VAL_OFFSET_IN_BEACON_INFO   0x12                                /**&amp;lt; Position of the MSB of the Major Value in m_beacon_info array. */
#define UICR_ADDRESS                    0x10001080                        /**&amp;lt; Address of the UICR register used by this example. The major and minor versions to be encoded into the advertising data will be picked up from this location. */
// #endif

#define TOGGLE                          0
#define DEBUG_TOGGLE(pin)               //nrf_gpio_pin_toggle(pin-4)

APP_TIMER_DEF(sleep_timer);
APP_TIMER_DEF(bas_timer);
APP_TIMER_DEF(adc_timer);

#define SAMPLES_IN_BUFFER 1
#define NUMBE_OF_ADC_CH   2

static bool module_advertising = false;
static ble_gap_adv_params_t m_adv_params;                                 /**&amp;lt; Parameters to be passed to the stack when starting advertising. */
static uint8_t m_beacon_info[APP_BEACON_INFO_LENGTH] =                    /**&amp;lt; Information advertised by the Beacon. */
{
    APP_DEVICE_TYPE,
    APP_ADV_DATA_LENGTH, // Manufacturer specific information. Specifies the length of the
                         // manufacturer specific data in this implementation.
    APP_BEACON_UUID,
    APP_MAJOR_VALUE,     // Major arbitrary value that can be used to distinguish between Beacons.
    APP_MINOR_VALUE,     // Minor arbitrary value that can be used to distinguish between Beacons.
};

/**@brief Callback function for asserts in the SoftDevice.
 *
 * @details This function will be called in case of an assert in the SoftDevice.
 *
 * @warning This handler is an example only and does not fit a final product. You need to analyze
 *          how your product is supposed to react in case of Assert.
 * @warning On assert from the SoftDevice, the system can only recover on reset.
 *
 * @param[in]   line_num   Line number of the failing ASSERT call.
 * @param[in]   file_name  File name of the failing ASSERT call.
 */
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
{
    app_error_handler(DEAD_BEEF, line_num, p_file_name);
}

/**@brief Function for initializing the Advertising functionality.
 *
 * @details Encodes the required advertising data and passes it to the stack.
 *          Also builds a structure to be passed to the stack when starting advertising.
 */
static void advertising_init(int8_t * p_tx_power_level, uint8_t * p_battery_level, uint8_t * p_adc_level)
{
    uint32_t      err_code;
    ble_advdata_t advdata;
    // uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

    ble_advdata_manuf_data_t manuf_specific_data;

    manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;

#if defined(USE_UICR_FOR_MAJ_MIN_VALUES)
    uint8_t index = MAJ_VAL_OFFSET_IN_BEACON_INFO;
    // If USE_UICR_FOR_MAJ_MIN_VALUES is defined, the major and minor values will be read from the
    // UICR instead of using the default values. The major and minor values obtained from the UICR
    // are encoded into advertising data in big endian order (MSB First).
    // To set the UICR used by this example to a desired value, write to the address 0x10001080
    // using the nrfjprog tool. The command to be used is as follows.
    // nrfjprog --snr &amp;lt;Segger-chip-Serial-Number&amp;gt; --memwr 0x10001080 --val &amp;lt;your major/minor value&amp;gt;
    // For example, for a major value and minor value of 0xabcd and 0x0102 respectively, the
    // the following command should be used.
    // nrfjprog --snr &amp;lt;Segger-chip-Serial-Number&amp;gt; --memwr 0x10001080 --val 0xabcd0102
    uint16_t major_value = ((*(uint32_t *)UICR_ADDRESS) &amp;amp; 0xFFFF0000) &amp;gt;&amp;gt; 16;
    uint16_t minor_value = ((*(uint32_t *)UICR_ADDRESS) &amp;amp; 0x0000FFFF);


    m_beacon_info[index++] = MSB_16(major_value);
    m_beacon_info[index++] = LSB_16(major_value);

    m_beacon_info[index++] = MSB_16(minor_value);
    m_beacon_info[index++] = LSB_16(minor_value);
#endif
    if (p_battery_level != NULL)
    {
      m_beacon_info[APP_BEACON_INFO_LENGTH -1] = *p_battery_level;
    }

    if (p_adc_level != NULL)
    {
      m_beacon_info[MAJ_VAL_OFFSET_IN_BEACON_INFO] = *p_adc_level;
    }

    manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
    manuf_specific_data.data.size   = APP_BEACON_INFO_LENGTH;

    // Build and set advertising data.
    memset(&amp;amp;advdata, 0, sizeof(advdata));

    advdata.name_type             = BLE_ADVDATA_FULL_NAME;
    // advdata.flags                 = flags;
    if (p_tx_power_level != NULL)
    {
        advdata.p_tx_power_level = p_tx_power_level;
    }
    advdata.p_manuf_specific_data = &amp;amp;manuf_specific_data;
    err_code = ble_advdata_set(&amp;amp;advdata, NULL);
    APP_ERROR_CHECK(err_code);

    // Initialize advertising parameters (used when starting advertising).
    memset(&amp;amp;m_adv_params, 0, sizeof(m_adv_params));

    m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
    m_adv_params.p_peer_addr = NULL;                             // Undirected advertisement.
    m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    m_adv_params.interval    = NON_CONNECTABLE_ADV_INTERVAL;
    m_adv_params.timeout     = APP_CFG_NON_CONN_ADV_TIMEOUT;
}


/**@brief Function for starting advertising.
 */
static void advertising_start(void)
{
    uint32_t err_code;

    err_code = sd_ble_gap_adv_start(&amp;amp;m_adv_params);
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for initializing the BLE stack.
 *
 * @details Initializes the SoftDevice and the BLE event interrupt.
 */
static void ble_stack_init(void)
{
    uint32_t err_code;

    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(&amp;amp;clock_lf_cfg, NULL);

    ble_enable_params_t ble_enable_params;
    err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                    PERIPHERAL_LINK_COUNT,
                                                    &amp;amp;ble_enable_params);
    APP_ERROR_CHECK(err_code);

    //Check the ram settings against the used number of links
    CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);

    // Enable BLE stack.
    err_code = softdevice_enable(&amp;amp;ble_enable_params);
    APP_ERROR_CHECK(err_code);
}

static void device_name_init(void)
{
    uint32_t                err_code;
    ble_gap_conn_sec_mode_t sec_mode;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode);

    err_code = sd_ble_gap_device_name_set(&amp;amp;sec_mode,
                                          (const uint8_t *)DEVICE_NAME,
                                          strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);
}

/**@brief Function for doing power management.
 */
static void power_manage(void)
{
    uint32_t err_code = sd_app_evt_wait();
    APP_ERROR_CHECK(err_code);
}

void advertise(uint8_t * p_battery_level, uint8_t * p_adc_level)
{
  if (module_advertising == false)
  {
    module_advertising = true;
    app_timer_start(sleep_timer, APP_TIMER_TICKS(ADV_PERIOD_MS, APP_TIMER_PRESCALER), NULL);
    advertising_init(NULL, p_battery_level, p_adc_level);
    advertising_start();
  }
}

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{

}

void saadc_init(void)
{
    ret_code_t err_code;
    nrf_saadc_channel_config_t channel_config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);

    nrf_drv_saadc_config_t saadc_config = NRF_DRV_SAADC_DEFAULT_CONFIG;
    saadc_config.resolution = NRF_SAADC_RESOLUTION_8BIT;
    err_code = nrf_drv_saadc_init(&amp;amp;saadc_config, saadc_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config);
    APP_ERROR_CHECK(err_code);

    channel_config.pin_p = NRF_SAADC_INPUT_AIN1;
    err_code = nrf_drv_saadc_channel_init(1, &amp;amp;channel_config);
    APP_ERROR_CHECK(err_code);
}

uint8_t adc_level_get(uint8_t channel)
{
  saadc_init();
  static nrf_saadc_value_t adc_lvl = 0;
  nrf_drv_saadc_sample_convert(channel, &amp;amp;adc_lvl);
  // APP_ERROR_CHECK(err_code);
  nrf_drv_saadc_uninit();
  NVIC_ClearPendingIRQ(SAADC_IRQn);
  return adc_lvl;
}


void sleep_timer_handler(void * p_context)
{
  DEBUG_TOGGLE(23);
  module_advertising = false;
  uint32_t err_code = sd_ble_gap_adv_stop();
  APP_ERROR_CHECK(err_code);
  __DSB();
  __NOP();
}

static uint8_t result;
void bas_timer_handler(void * p_context)
{
  uint8_t lvl = adc_level_get(0);
  uint16_t vbg_in_mv = 600;
  uint8_t adc_max = 255;
  uint16_t vbat_current_in_mv = (lvl * 6 * vbg_in_mv) / adc_max;

  if (vbat_current_in_mv &amp;gt; 2800)
  {
    result = 0;
  }
  else if (vbat_current_in_mv &amp;gt; 2700)
  {
    result = 1;
  }
  else if (vbat_current_in_mv &amp;gt; 2600)
  {
    result = 2;
  }
  else
  {
    result = 3;
  }


  advertise(&amp;amp;result, NULL);
}

static uint8_t lvl;
void adc_timer_handler(void * p_context)
{
  DEBUG_TOGGLE(22);
  lvl = adc_level_get(1);
  advertise(NULL, &amp;amp;lvl);
}

void init_timer(void)
{
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    uint32_t err_code = app_timer_create(&amp;amp;sleep_timer,
                                        APP_TIMER_MODE_SINGLE_SHOT,
                                        sleep_timer_handler);
    err_code = app_timer_create(&amp;amp;bas_timer,
                                APP_TIMER_MODE_REPEATED,
                                bas_timer_handler);
    err_code = app_timer_create(&amp;amp;adc_timer,
                                APP_TIMER_MODE_REPEATED,
                                adc_timer_handler);
    APP_ERROR_CHECK(err_code);
}

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
  DEBUG_TOGGLE(22);
  // uint8_t lvl = battery_level_get();
  advertise(NULL, NULL);
}

static void gpio_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
    in_config.pull = NRF_GPIO_PIN_PULLUP;

    err_code = nrf_drv_gpiote_in_init(WAKE_GPIO, &amp;amp;in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(WAKE_GPIO, true);
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    static int8_t tx_power_level = TX_POWER_LEVEL;

#if TOGGLE
    // nrf_gpio_cfg_output(17);
    // nrf_gpio_cfg_output(18);
    // nrf_gpio_cfg_output(19);
#endif

    // NRF_POWER-&amp;gt;DCDCEN = 1;  
    init_timer();    
    app_timer_start(bas_timer, APP_TIMER_TICKS((BAT_MEASURE_PERIOD_MINUTES * 60 * 1000), APP_TIMER_PRESCALER), NULL);
    nrf_delay_ms(100);
    app_timer_start(adc_timer, APP_TIMER_TICKS((ADC_MEASURE_PERIOD_MINUTES  * 1000), APP_TIMER_PRESCALER), NULL);
    gpio_init();
    // Enter main loop.
    ble_stack_init();
    sd_ble_gap_tx_power_set(tx_power_level);
    device_name_init();

    for (;; )
    {
      power_manage();
      // DEBUG_TOGGLE(21);
    }
}


/**
 * @}
 */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is code for my nrf52 port. In the test where I got 200uA it was only WFE in main loop without any initilization. Also I was trying to trigger hfclk stop task but without any change in consumption. I will test system off later.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High current consumption on nrf52 dk</title><link>https://devzone.nordicsemi.com/thread/136680?ContentTypeID=1</link><pubDate>Tue, 19 Jun 2018 08:35:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c58aef5e-59d1-4e46-894d-77c9f31a3b29</guid><dc:creator>H&amp;#229;vard</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;To verify that there is nothing wrong with the board itself, could you try to go to system-off? (Just copy the code below &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/263a.svg" title="Relaxed"&gt;&amp;#x263a;&lt;/span&gt;) This should bring the consumption down to ~ 300 nA. Consumption around 200uA can indicate that the high frequency clock is running. Maybe I could see more of your code to verify it?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    NRF_POWER-&amp;gt;SYSTEMOFF = 1;

    while (true)
    {
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>