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

I2C peripheral increase power after first transfer and de-init

Hello,

I have a problem with the I2C peripheral on my nrf53840.

I enable i2c driver on my project and read sensors on the bus. Everything is OK. Then when with Power management I disable i2c for low power but i have an extra consumption of ~60 ua.

If I enable i2c driver but do not transfer with the sensor and apply Power management, the consumption is OK. The problem seems to be appearing only after a first i2c transfer (Read or Write).

&i2c2 {
compatible = "nordic,nrf-twim";
status = "okay";
sda-pin = <44>; /* 32 +12 */
scl-pin = <43>; /* 32 + 11 */
clock-frequency = <I2C_BITRATE_STANDARD>;

lsm6dso@6a {
compatible = "st,lsm6dso";
reg = <0x6a>;
irq-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>, <&gpio0 4 GPIO_ACTIVE_HIGH>;
label = "LSM6DSO";
};

lis2mdl@1e {
compatible = "st,lis2mdl";
reg = <0x1e>;
irq-gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; /* A2 */
label = "LIS2MDL";
};
};
On the main, the i2c part:
#define I2C_LABEL DT_LABEL(DT_NODELABEL(i2c2))
const struct device *i2cDev = device_get_binding(I2C_LABEL);
if(i2cDev != NULL)
{
LOG_INF("Disable i2c peripheral");
pm_device_state_set(i2cDev, PM_DEVICE_STATE_LOW_POWER);
}
Parents
  • I'm currently looking into this

    Best regards,

    Simon

  • Sorry for the delay, I've been quite busy lately. I will prioritize this the next days.

    By the way, I though Zephyr would handle power management automatically. What happens if you don't disable I2C after a transfer, what current consumption do you measure then?

    Best regards,

    Simon

  • I found the problem. In fact, it's not the i2c peripheral but when i need to configure a gpio on interrupt mode.

    #ifdef CONFIG_LSM6DSO_TRIGGER
    	if (cfg->trig_enabled) {
    		if (lsm6dso_init_interrupt(dev) < 0) {
    			LOG_ERR("Failed to initialize interrupt.");
    			return -EIO;
    		}
    	}
    #endif

    When i enable lsm6 on interrupt, the extra consumption of ~60 ua appear.

    The gpio part in lsm6dso

    ret = gpio_pin_configure_dt(&cfg->gpio_drdy, GPIO_INPUT);
    	if (ret < 0) {
    		LOG_DBG("Could not configure gpio");
    		return ret;
    	}
    
    	gpio_init_callback(&lsm6dso->gpio_cb,
    			   lsm6dso_gpio_callback,
    			   BIT(cfg->gpio_drdy.pin));
    
    	if (gpio_add_callback(cfg->gpio_drdy.port, &lsm6dso->gpio_cb) < 0) {
    		LOG_DBG("Could not set gpio callback");
    		return -EIO;
    	}
    
    	/* enable interrupt on int1/int2 in pulse mode */
    	if (lsm6dso_int_notification_set(ctx, LSM6DSO_ALL_INT_PULSED) < 0) {
    		LOG_DBG("Could not set pulse mode");
    		return -EIO;
    	}
    
    	return gpio_pin_interrupt_configure_dt(&cfg->gpio_drdy,
    					       GPIO_INT_EDGE_TO_ACTIVE);

    I try to configure my button also on interrupt mode (with the zephyr sample) and i found the same behaviour.

    With nrf5340 need to specify something else on GPIO for interrupt ?

  • Try setting CONFIG_GPIO_NRF_INT_EDGE_USING_SENSE=y in the prj.conf. According to the Kconfig Reference, it may cause a decreased current consumption.

    I tested this with the sample zephyr/samples/basic/button (which uses gpio interrupts) and saw that the current consumption decreased from ~60uA to 2.2uA.

    I will look more into this configuration tomorrow, what it does exactly, and if it has any consequences for your application.

    Best regards,

    Simon

Reply
  • Try setting CONFIG_GPIO_NRF_INT_EDGE_USING_SENSE=y in the prj.conf. According to the Kconfig Reference, it may cause a decreased current consumption.

    I tested this with the sample zephyr/samples/basic/button (which uses gpio interrupts) and saw that the current consumption decreased from ~60uA to 2.2uA.

    I will look more into this configuration tomorrow, what it does exactly, and if it has any consequences for your application.

    Best regards,

    Simon

Children
No Data
Related