This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ27426: Not gauging

Part Number: BQ27426

Tool/software:

Hey, I have a problem that the used gauge is not updating the state of charge after soft reset. 

Following code is how i config the gauge now:

retval BQ27426::InitModule()
{
    CHECK_RV(i2c_master_.Probe(kI2cAddress, 100_ms, 5_ms));

    CHECK_RV(ControlSubCommandWrite(CNTLData::kUnseal));
    CHECK_RV(ControlSubCommandWrite(CNTLData::kUnseal));
    
    uint16_t battery_capacity_ = 40;
    uint16_t design_energy_ = 148;
    uint16_t terminate_voltage_ = 3000;
    uint16_t taper_rate_ = 500;
    
    static const uint8_t kDesignCapcityOffset = 6;
    static const uint8_t kOpConfigDOffset = 4;
    static const uint8_t kTaperRateOffset = 21;
    static const uint8_t kOpConfigDChemistryMask = 0x08; // Set Chem ID to 1202
    
    static const uint8_t kBatLowEnMask = 0x7D;
    static const uint8_t kGpioPolMask = 0x6C;
    static const uint8_t kOpConfig3Mask = 0xDF;
    

    // Set battery configurations, these are all located after each other in the memory
    etl::array<int16_t, 3> capacity_config({battery_capacity_, design_energy_, terminate_voltage_});
    CHECK_RV(SetConfiguration(
        FlashSubclass::kState, kDesignCapcityOffset,
        etl::span<uint8_t>((uint8_t *)capacity_config.begin(), sizeof(uint16_t) * 3), false));

    CHECK_RV(SetConfiguration(FlashSubclass::kState, kTaperRateOffset,
                              etl::span<uint8_t>((uint8_t *)&taper_rate_, sizeof(uint16_t)),
                              false));

    // Set battery chemistry
    etl::array<uint8_t, 1> chemistry_config({kOpConfigDChemistryMask});
    CHECK_RV(SetConfiguration(FlashSubclass::kRegisters, kOpConfigDOffset, chemistry_config, true));

    // Enable interrupt on capacity and pin output
    etl::array<uint8_t, 4> pin_config({kGpioPolMask, kBatLowEnMask, 0x00, kOpConfig3Mask});
    CHECK_RV(SetConfiguration(FlashSubclass::kRegisters, 0, pin_config, true));

    CHECK_RV(ControlSubCommandWrite(CNTLData::kChemB));

    // Make the sensor operational
    CHECK_RV(ControlSubCommandWrite(CNTLData::kSoftReset));

    // Wait for flag to reset
    // Somehow waiting for flag does not work. flag is always set
    // Just wait for 1 sec here
    vTaskDelay(1000);

    CHECK_RV(ControlSubCommandWrite(CNTLData::kSealed));

    /* force the BAT_DET bit to one */
    CHECK_RV(ControlSubCommandWrite(CNTLData::kBatInsert));

    is_initialized_ = true;
    return retval::kSuccess;
}

Reading the registers back all values are set correct.

Exact used component: BQ27426YZFR

The gauge never updates the stage of charge register. Only after a soft reset. 

I'm not sure what to do now to solve this problems. Any ideas? 

Kind regard, Diede