This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9160 GPIO consume higher current when configure as input

Hi,

I am using ncs V1.0.0 

When I configure P0.5 as input it takes 37uA current. (Interface with PCA63548 / LIS2DH Interrupt)

If I not configure the pin as input getting desired current around 7uA.

GPIOTE config as input with below configuration:

Fullscreen
1
2
3
4
5
6
7
8
#define INT2_PIN 5
gpio_int2 = device_get_binding(DT_GPIO_P0_DEV_NAME);
gpio_pin_configure(gpio_int2, INT2_PIN, (GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE | GPIO_PUD_PULL_DOWN | GPIO_INT_ACTIVE_HIGH ) );
gpio_init_callback(&gpio_cb, lis2dh12_interrupt2_isr, BIT(INT2_PIN));
gpio_add_callback(gpio_int2,&gpio_cb);
error = gpio_pin_enable_callback(gpio_int2,INT2_PIN);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Used below peripheral configuration in overlay file.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
&spi3 {
status = "ok";
sck-pin = <13>;
mosi-pin = <11>;
miso-pin = <12>;
spi-max-frequency = <4000000>;
};
&uart2 {
status = "ok";
current-speed = <9600>;
tx-pin = <10>;
rx-pin = <17>;
rts-pin = <27>;
cts-pin = <26>;
};
&adc {
status = "ok";
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

-Nirav Patel

  • Hi,

    The GPIOTE peripheral can either use the IN event or the PORT event(sense mechanism) to trigger an interrupt. When you set the flag GPIO_INT_EDGE, the zephyr gpio driver will use a GPIOTE IN channel(IN EVENT) for the pin, this will consume some additional current (10 - 20 uA range).

    The low-power option is to use PORT event instead. Looking at the zephyr driver, you then need to set GPIO_INT_LEVEL. You can read about the Pin sense mechanism here. Note that PORT DETECT signal is shared by multiple pins, so if you are using multiple input pins that changes level at about the same time, and at a high frequency, it might be better to use IN event.

  • Hi,

    Thanks using "GPIO_INT_LEVEL" reduced the current.

    Regards,

    Nirav Patel

  • When I configure the button in this mode my current drops as expected, however now I have 3mA of current while the button is held. Is this expected or am I doing something wrong? In edge mode the increase while holding the button was 50uA

  • For anyone encountering the same situation I ended up disabling the interrupt callback while servicing the interrupt. I believe that in LEVEL mode the interrupt will be fired constantly while the line is held.