This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

reducing current consumption of nrf5340 GPIO interrupts configured for edge triggering

I have a few GPIOs configured as interrupt pins.. most are edge triggered GPIO_INT_EDGE_FALLING or GPIO_INT_EDGE_RISING (won't work otherwise so, i cant go for level triggered at this time)..Only button is GPIO_INT_LEVEL_INACTIVE..  Looks like in 1.9.1 we need to add an entry in overlay to take care of masking for sense-edge and i did..

&gpio0 {
status = "okay";
sense-edge-mask = < 0xffffffff >;
};

&gpio1 {
status = "okay";
sense-edge-mask = < 0xffffffff >;
};

Will making interrupts edge triggered add lot 10s of extra uA like it is mentioned in some older tickets ? is there a way around that I am missing ?

Older tickets talked about using CONFIG_GPIO_NRF_INT_EDGE_USING_SENSE but as we all know that macro doesn't seem to exist anymore.. some ticket mentioned setting hi_accuracy parameter to false for gpio config.. some ticket mentioned setting low latency to 0  (haven't found a zephyr api to do that yet( but I am using the interrupt set up as follows and can't find any other  way

Is there a way to use edge triggered interrupts and not take up too much power at all ?  I have searched as much as I could but couldn't get anywhere.. I have 5 gpios configured and hence any current saved will be awesome.

  • here's one example of how I set up the interrupt.. and please note that this works exactly as expected and there are no issues.. level triggering does not work and hence i can;t use it.. question is only about finding a way to use edge triggered interrupts that don;t take too much power

    bool xx_nrf5340_gpio_interrupt_for_xx_setup(void) {
    int ret;
    xx_nrf5340_gpio_1_init();
    gpio_pin_configure(gpio_1_dev, NRF53440_GPIO_PIN_FOR_xx_INTR, GPIO_INPUT);

    ret = gpio_pin_interrupt_configure(gpio_1_dev, NRF53440_GPIO_PIN_FOR_xx_INTR, GPIO_INT_EDGE_FALLING);
    if (ret != 0) {
    printk("Error %d: failed to configure xx interrupt pin %d\n", ret, NRF53440_GPIO_PIN_FOR_xx_INTR);
    return false;
    }


    gpio_init_callback(&xx_cb,
    xx_intr_process,
    BIT(NRF53440_GPIO_PIN_FOR_xx_INTR));

    gpio_add_callback(gpio_1_dev, &xx_cb);
    return true;
    }

  • Hi,

    Several of our experts on this are out of office, but I will check internally and get back to you.

    Best regards,

    Marte

  • Hi,

    CONFIG_GPIO_NRF_INT_EDGE_USING_SENSE does not exist anymore because it was replaced by the sense-edge-mask property. Using sense edge detection should reduce the current consumption compared to using GPIO edge triggering, as this emulates edge triggering with GPIOTE SENSE instead of GPIOTE IN. 

    Make sure that you are configuring the sense-edge-mask property correctly, as Stian writes in his comment here:  RE: nRF9160: LIS2DW12 high current consumption .

    You should also change GPIO_INT_EDGE_FALLING in gpio_pin_interrupt_configure() to GPIO_INT_TRIG_BOTH instead.

    Please note that this is emulated, meaning that the CPU runs logic to make this happen. If the GPIO edges are very close to each other in time, the cpu might not be able to register the change in certain use-cases (ie. its blocked by a higher interrupt or similar).

    Best regards,

    Marte

  • thank you for the reply.. my original post already shows my sense-edge-mask config value.. i am pasting it below.. this should be fine right ? os will the masking all create any issues ?

    &gpio0 {
    status = "okay";
    sense-edge-mask = < 0xffffffff >;
    };

    &gpio1 {
    status = "okay";
    sense-edge-mask = < 0xffffffff >;
    };

    I will try the GPIO_INT_TRIG_BOTH .. is that because of what you mentioned about emulated interrupt ?

  • Hi,

    sshenoy105 said:
    this should be fine right ? os will the masking all create any issues ?

    Yes, my mistake. When enabling the sense mechanism for all pins setting sense-edge-mask to 0xffffffff is correct and should be fine.

    sshenoy105 said:
    I will try the GPIO_INT_TRIG_BOTH .. is that because of what you mentioned about emulated interrupt ?

    That is correct. GPIO sense is a level interrupt mechanism emulating edge triggering, which is why you should use GPIO_INT_TRIG_BOTH instead.

    Please let me know if you see any changes in current consumption or not using this.

    Best regards,

    Marte

Related