npm1300 readings delayed by one measurement

Hi,

I am using the npm1300 with the nrf9160 with ncs2.7

When we do a reading from the npm1300 to get the current and voltage values, the readings are always delayed by 1 reading.  So for example, if I have the voltage set to 3.7V, and then change it to 3.6V and wait several seconds, when I read the pmic values it reads 3.7V.  If I read again it shows 3.6V.

Here is the code we are using for reading. I am working on getting an i2c trace of the communication

void pmic_read_sensors(void)
{
    struct sensor_value volt;
    struct sensor_value current;
    struct sensor_value temp;
    struct sensor_value error;
    struct sensor_value status;

    sensor_sample_fetch(charger);
    sensor_channel_get(charger, SENSOR_CHAN_GAUGE_VOLTAGE, &volt);
    sensor_channel_get(charger, SENSOR_CHAN_GAUGE_AVG_CURRENT, &current);
    sensor_channel_get(charger, SENSOR_CHAN_GAUGE_TEMP, &temp);
    sensor_channel_get(charger, SENSOR_CHAN_NPM1300_CHARGER_STATUS, &status);
    sensor_channel_get(charger, SENSOR_CHAN_NPM1300_CHARGER_ERROR, &error);

    LOG_DBG("V: %d.%03d ", volt.val1, volt.val2 / 1000);

    LOG_DBG("I: %s%d.%04d ", ((current.val1 < 0) || (current.val2 < 0)) ? "-" : "", abs(current.val1),
            abs(current.val2) / 100);

    LOG_DBG("T: %s%d.%02d", ((temp.val1 < 0) || (temp.val2 < 0)) ? "-" : "", abs(temp.val1), abs(temp.val2) / 10000);

    LOG_DBG("Charger Status: %d, Error: %d", status.val1, error.val1);
}

Related