High power consumption on simple GPIO interrupt application

Hello, nordic team

I have encountered unusually high power consumption in a simple GPIO edge interrupt application running on a custom nRF9160 board. The application is developed using the nRF Connect SDK v2.5.2. 

The application consumes around 4mA with the bare minimum config in idle (I expect the idle power consumption should be nearly my board floor level current 7 - 8uA).
However, the board consumes differently if I first flash my current floor-level testing appliaction and then flash the GPIO edge interrupt appliaction,
the power consumption of GPIO interrupt application drastically drops to 7-8uA. 

I suspected that some setting/peripherals were not initialized correctly; unfortunately, I can't pinpoint which setting/peripherals are the root cause. I would appreciate it if someone could provide some insights. I attached the code, prj.conf, and devicetree overlay of both appliaction below. Thank you. 

Anthony

------------------------------------------------------------------------------------------------------------------------------------

GPIO edge interrupt firmware

Here is the code snippet of main.c

static void pulse_count_gpio_init (struct gpio_dt_spec pulse){
	int ret;

	ret = gpio_pin_configure(pulse.port,pulse.pin,GPIO_INPUT);
	ret = gpio_pin_interrupt_configure(pulse.port,pulse.pin,GPIO_INT_EDGE_FALLING);
	gpio_init_callback(&pulse_cb_data,pulse_detected,BIT(pulse.pin));
	gpio_add_callback(pulse.port,&pulse_cb_data);
}

int main(void)
{
	LOG_INF("Pulse count sample started");
	pulse_count_gpio_init(pulse);

	while (1) 
	{
	LOG_INF("Pulse count: %i", cnt);
	k_msleep(SLEEP_TIME_MS);
	}

	return 0;
}

prj.conf

CONFIG_SERIAL=n
CONFIG_LOG=y

CONFIG_GPIO=y
CONFIG_NRFX_TIMER0=y
CONFIG_NRFX_GPIOTE=y
CONFIG_NRFX_DPPI=y

CONFIG_PM_DEVICE=y

devicetree overlay

/{
    zephyr,user{
        pulse_in-gpios = <&gpio0 20 0>;
    };

};

// For lowest power interrupt, sense-edge-mask must be enabled for designed pin.
// For setting single pin 20, set sense-edge-mask to <(1 << 20)> or <0x100000> or <20>
// For setting multiple pins (29/30), set sense-edge-mask = <((1 << 29) | (1 << 30))>;
&gpio0 {
	// sense-edge-mask = <(1 << 20)>;
    sense-edge-mask = <0x100000>;
};

------------------------------------------------------------------------------------------------------------------------------------

Current floor-level testing firmware

main.c

#include <stdio.h>
#include <zephyr/kernel.h>
#include <modem/nrf_modem_lib.h>
#include <modem/lte_lc.h>

int main(void)
{	
	int err; 

	err = nrf_modem_lib_init();

	//  lte_lc_init() cause the nRF to with extreme current
	// err = lte_lc_init();
	// if(err) {
	// 	return 0;
	// }

	err = lte_lc_offline();
	k_sleep(K_MSEC(1000));
 	NRF_REGULATORS->SYSTEMOFF = 1;
	return 0;
}

prj.conf

# Stacks and heaps
# CONFIG_MAIN_STACK_SIZE=4096
# CONFIG_HEAP_MEM_POOL_SIZE=16384

# Console Output
CONFIG_CONSOLE=n

CONFIG_SERIAL=n # Disable Serial to ensure lowest power consumption
CONFIG_TFM_LOG_LEVEL_SILENCE=y
CONFIG_USE_SEGGER_RTT=n
CONFIG_RTT_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_PRINTK=n
CONFIG_LOG_PRINTK=n

# Peripherals
CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_GPIO=n   # GPIO
CONFIG_I2C=n    # I2C

# Zephyr Device Power Management
CONFIG_PM_DEVICE=y
CONFIG_PM=y

# Network
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS_POSIX_NAMES=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y

# Modem 
CONFIG_NRF_MODEM_LIB=y


Related