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.

BQ25730: Power up on battery, design help

Genius 17385 points
Part Number: BQ25730
Other Parts Discussed in Thread: BQ25731

Hi Experts,

Good day. Asking your assistance on this query:

I am using the BQ25730 in a battery powered product. When the battery is changed the BQ25730 will not go into full operating mode allowing A/D voltage readings until the product is supplied with external power. From the Data sheet, power up sequence when the charger is powered up from VBAT:
...
Device can move to performance mode by configuring EN_LWPWR = 0b.
I do not find this to enable the A/D. I do not use/enable any of the CMPOUT, PSYS, IADPT, IBAT or PROCHOT pin functions.
I do read the I2C registers to get battery voltage and current, but these are 0 until external/vbus power is supplied.

Thanks for your help.

Regards,
Archie A.

  • Hello Archie,

    When running from VBAT, initial powerup is in Low Power Mode. After exiting Low Power Mode by setting EN_LWPWR=0b, the ADC should be available for use. Please confirm that you fully enable the ADC after setting EN_LWPWR = 0b as it needs to be enabled after exiting Low Power Mode.

    Thanks,
    Khalid

  • Hi Khalid,

    Thanks for the support.

    I think I am doing the initialization in the correct sequence. I have attached excerpts of my initialization code.

    I have tried one shot and continuous conversion and neither works.

    Regards,
    Archie A.

    #define BQ_CHARGE_OPTION_0      0x00 
    #define  BQ_CHRG_OPT_0_EN_LPWR          0x8000
    #define  BQ_CHRG_OPT_0_WDTMR_ADJ_SEC    0x2000 // 0x6000 // wdt secs: 0 = off, 1 = 5, 2 = 88, 3 = 175 (POR default)
    #define  BQ_CHRG_OPT_0_IIN_DPM_AUTO_DISABLE 0x1000
    #define  BQ_CHRG_OPT_0_EN_OOA           0x0400
    #define  BQ_CHRG_OPT_0_PWM_FREQ         0x0200
    #define  BQ_CHRG_OPT_0_LOW_PTM_RIPPLE   0x0100
    #define  BQ_CHRG_OPT_0_EN_CMP_LATCH     0x0080
    #define  BQ_CHRG_OPT_0_VSYS_UVP_ENZ     0x0040
    #define  BQ_CHRG_OPT_0_EN_LEARN         0x0020
    #define  BQ_CHRG_OPT_0_IADPT_GAIN       0x0010
    #define  BQ_CHRG_OPT_0_IBAT_GAIN        0x0008
    #define  BQ_CHRG_OPT_0_EN_LDO           0x0004
    #define  BQ_CHRG_OPT_0_EN_IIN_DPM       0x0002
    #define  BQ_CHRG_OPT_0_CHRG_INHIBIT     0x0001
    #define  BQ_CHRG_OPT_0_ADPT             (BQ_CHRG_OPT_0_WDTMR_ADJ_SEC | BQ_CHRG_OPT_0_IIN_DPM_AUTO_DISABLE | \
                                               BQ_CHRG_OPT_0_PWM_FREQ | BQ_CHRG_OPT_0_EN_LDO | BQ_CHRG_OPT_0_EN_IIN_DPM)
    #define  BQ_CHRG_OPT_0_BATT_SLEEP       (BQ_CHRG_OPT_0_EN_LPWR | BQ_CHRG_OPT_0_WDTMR_ADJ_SEC | BQ_CHRG_OPT_0_IIN_DPM_AUTO_DISABLE | \
                                               BQ_CHRG_OPT_0_PWM_FREQ | BQ_CHRG_OPT_0_EN_LDO | BQ_CHRG_OPT_0_EN_IIN_DPM)
    #define BQ_CHARGE_CURRENT_SET   0x02    // page 49 strange split of nibbles
    #define BQ_CHARGE_VOLTAGE_SET   0x04    // page 51
    #define BQ_VIN_MIN_SET          0x0A
    #define BQ_VSYS_MIN_SET         0x0C
    #define BQ_IIN_MAX_SET          0x0E
    #define BQ_CHARGER_STATUS       0x20
    #define  BQ_CHRG_STAT_STAT_AC           0x8000
    #define  BQ_CHRG_STAT_ICO_DONE          0x4000
    #define  BQ_CHRG_STAT_IN_VAP            0x2000
    #define  BQ_CHRG_STAT_IN_VINDPM         0x1000
    #define  BQ_CHRG_STAT_IN_IIN_DPM        0x0800
    #define  BQ_CHRG_STAT_IN_FCHRG          0x0400
    #define  BQ_CHRG_STAT_IN_PCHRG          0x0200
    #define  BQ_CHRG_STAT_IN_OTG            0x0100
    #define  BQ_CHRG_STAT_FAULT_ACOV        0x0080
    #define  BQ_CHRG_STAT_FAULT_BATOC       0x0040
    #define  BQ_CHRG_STAT_FAULT_ACOC        0x0020
    #define  BQ_CHRG_STAT_FAULT_SYSOVP      0x0010
    #define  BQ_CHRG_STAT_FAULT_VSYS_UVP    0x0008
    #define  BQ_CHRG_STAT_FAULT_FORCE_OFF   0x0004
    #define  BQ_CHRG_STAT_FAULT_OTG_OVP     0x0002
    #define  BQ_CHRG_STAT_FAULT_OTG_UVP     0x0001
    
    #define BQ_PROCHOT_STATUS       0x22
    #define BQ_IIN_DPM              0x24
    #define BQ_ADCVBUS_PSYS         0x26
    #define BQ_ADCIBAT              0x28
    #define BQ_ADCIIN_CMPIN         0x2A
    #define BQ_ADCVSYS_VBAT         0x2C
    #define BQ_IDS                  0x2E
    #define  BQ_MANUFACTURERID_DEVICE_ID    0x40
    #define BQ_CHARGE_OPTION_1      0x30
    #define BQ_CHARGE_OPTION_2      0x32
    #define BQ_CHARGE_OPTION_3      0x34
    #define  BQ_CHRG_OPT_3_DEFAULT          0x0428 
    #define  BQ_CHRG_OPT_3_RESET_REG        (0x4000 | BQ_CHRG_OPT_3_DEFAULT)
    #define BQ_PROCHOT_OPT_0        0x36
    #define BQ_PROCHOT_OPT_1        0x38
    #define  BQ_PROCHOT_OPT_1_DEFAULT 0x4100  
    #define BQ_ADC_OPTION           0x3A
    #define  ADC_OPTION_CONFIG              0x605F
    #define BQ_CHARGE_OPTION_4      0x3C
    //#define  BQ_CHRG_OPT_4_DEFAULT          0x0048 // 0 frequency dithering, rest POR default. diterhing impacts conducted EMI??
    //#define  BQ_CHRG_OPT_4_DEFAULT          0x1048 // 2% frequency dithering, rest POR default. diterhing impacts conducted EMI??
    //#define  BQ_CHRG_OPT_4_DEFAULT          0x0848 // 4% frequency dithering, rest POR default. diterhing impacts conducted EMI??
    #define  BQ_CHRG_OPT_4_DEFAULT          0x1848 // 6% frequency dithering, rest POR default. diterhing impacts conducted EMI??
    #define BQ_VMIN_ACTIVE_PROTECTION 0x3E
    
    void BqChargeCurrentSet(uint16_t milliamps) {
        uint16_t reg = ((milliamps / 2) + 0x20) & 0x1FC0; // round 
        I2cWriteBQWord(BQ_CHARGE_CURRENT_SET, reg);
    }
    
    void BqChargeVoltagetSet(uint16_t millivolts) {
        uint16_t reg = millivolts & 0x7FF8;
        I2cWriteBQWord(BQ_CHARGE_VOLTAGE_SET, reg);
    }
    
    void BqIInMaxSet(uint16_t milliamps) {
        uint16_t reg = (milliamps / 100) << 8;
        I2cWriteBQWord(BQ_IIN_MAX_SET, reg);
    }
    
    void BqVInMinSet(uint16_t millivolts) {
        millivolts -= 3200;
        if (millivolts > 0x3FC0) millivolts = 0x3FC0;
        uint16_t vInMin = millivolts & 0x3FC0;  
        I2cWriteBQWord(BQ_VIN_MIN_SET, vInMin);
    }
    
    void BqVSysMinSet(uint16_t millivolts) {
        uint16_t vSysMin = (millivolts / 100) << 8;  
        I2cWriteBQWord(BQ_VSYS_MIN_SET, vSysMin);
    }
    
    void BqEnableLowPower(bool enableLowPower) {
        if (enableLowPower == TRUE) {
            if (I2cWriteBQWord(BQ_CHARGE_OPTION_0, BQ_CHRG_OPT_0_BATT_SLEEP) == TRUE) {
                bqInfo.option0 = BQ_CHRG_OPT_0_BATT_SLEEP;        
            }
        } else if (I2cWriteBQWord(BQ_CHARGE_OPTION_0, BQ_CHRG_OPT_0_ADPT) == TRUE) {
            bqInfo.option0 = BQ_CHRG_OPT_0_ADPT;
        }
    }
    
    void ChargerInit(void) {
                I2cWriteBQWord(BQ_CHARGE_OPTION_3, BQ_CHRG_OPT_3_RESET_REG);
                DelayMs(10); //allow time for reset
                I2cWriteBQWord(BQ_CHARGE_OPTION_3, BQ_CHRG_OPT_3_DEFAULT);
                BqEnableLowPower(false);
                BqChargeVoltagetSet(DefaultChargeVoltage);
                BqVSysMinSet(DefaultVSysMin);
                BqVInMinSet(CarVoltageMin);
                I2cWriteBQWord(BQ_CHARGE_OPTION_4, BQ_CHRG_OPT_4_DEFAULT);   
                I2cWriteBQWord(BQ_ADC_OPTION, ADC_OPTION_CONFIG);  
                I2cWriteBQWord(BQ_PROCHOT_OPT_1, BQ_PROCHOT_OPT_1_DEFAULT);
    }

  • Hello Archie,

    I reviewed the code and I don't see any mistake or issue. I reproduced this setup on my bench with EVM and I see the ADC updating with correct measurements when in Battery only mode.

    Here are the steps I took:

    - Power up with VBAT = 7V

    - Set EN_LWPWR=0

    - Update ADCOption to 0x605F (these are the settings used in your code)

    - Read back VSYS/VBAT Voltage -> it is updated as expected

    I would recommend to try those steps in isolation and confirm it is working (there are some other register writes in between that I was not able to verify due to some of the variables not defined in the code you sent). Oherwise I would also recommend to readback the register to make sure it was updated (when setting EN_LWPWR to 0 and the ADCOption register).

    Thanks,
    Khalid

  • Khalid,

    Sorry for the late response as Cx just returned back.

    On the eval board is there enough voltage leakage back to VBUS to bring VBUS up to a level that turns the REGN on, and then therefore the A/D?

    Datasheet: " The LDO is active when VBUS above VVBUS_CONVEN . " We have some load on the VBus side that will keep it down when the unit is running from the battery.

    Thank you.

    Regards,
    Archie A.

  • Archie,

    I reproduced this again and monitored VBUS. It does not rise above 250mV.

    Please ask the customer for an even simpler procedure:

    - Power up with VBAT = 7V

    - Set EN_LWPWR=0

    - Measure REGN Voltage

    On the EVM Setup, the REGN voltage immediately goes up to 6V as soon as I set EN_LWPWR=0.

    If this does not happen they need to review the HW schematic against the EVM.

    Thanks,

    Khalid

  • Hi Khalid,

    Thanks for this guide, This was helpful.

    The customer used a scope found that REGN does come up but as soon as he set PP_ICRIT, bit 5 in register 38h, to 0 the REGEN goes away. Does this make sense?

    Thank you.

    Regards,
    Archie A.

  • Archie,

    I am not sure why that would be the case. This bit is for the PROCHOT feature and my understanding is that it shouldn't cause the REGN to go low if this feature is enabled. I will try to reproduce this on Monday and let you know the result.

    Thanks,

    Khalid

  • Archie,

    I tried to reproduce this and the REGN does not go low under any circumstance when changing any of the PROCHOT settings.

    Please ask the customer to read back ChargeOption0 register to ensure they did not accidentally reset the device into EN_LWPWR mode which would drop REGN. They can also monitor the VBAT during this sequence to see if it is possible their input voltage is dropping out causing a reset.

    Thanks,
    Khalid

  • Hello Khalid,

    Got respons from Cx:

    Note: to recreate this you must remove the battery and then install. It is on the first battery power up that the problem occurs. Here is a memory dump of the BQ in the 2 different conditions. Note that bit 5 in register 0x38 is different.

    BQ Memory dump when REGN stays on:

    00 3206 0000 36b0 09c4 3c00 0000 7300 2000
    10 ffff ffff ffff ffff ffff ffff ffff ffff
    20 0000 b880 2000 0000 0000 0000 0000 d540
    30 3f00 00b7 0428 4a09 4020 605f 1848 0004


    BQ memory dump when REGN goes off

    00 3206 0000 36b0 09c4 3c00 0000 7300 2000
    10 ffff ffff ffff ffff ffff ffff ffff ffff
    20 0000 b880 2000 0000 0000 0000 0000 d540
    30 3f00 00b7 0428 4a09 4000 605f 1848 0004

    Thank you.

    Regards,
    Archie A.

  • Hi Archie,

    Going back to the original question, the customer stated that the ADC was not working when powering up with Battery only. Reading the two register dumps, below is what I see. Please correct me if I am misreading this:

    ADCOption (0x3A = 605F):
    60: 1 Shot, ADC_START enabled, ADC_FULLSCALE selected
    5F: Enable VBUS, PSYS, IDCHG, ICHG, VSYS, VBAT ADC measurement

    Reading the rest of the register dump, I see the following in the ADC Measurement registers:
    0x26(VBUS/PSYS): 0000 -> Enabled, but VBUS is unplugged and PSYS is unused, so 0 is correct
    0x28(ICHG/IDCHG): 0000 -> Enabled, but VBUS is unplugged, so ICHG should be 0. IDCHG is 0, but LSB is 512mA. 0 is probably valid depending on system load
    0x30(IIN/CMPIN): 0000 -> Disabled
    0x32(VSYS/VBAT): D540 -> Enabled, VSYS = 13.632V, VBAT = 4.096V

    These seem like reasonable values to me for VSYS and VBAT and the rest of the values make sense why they are zero. Please ask the customer to review this and let me know if there is still an issue.

    Thanks,
    Khalid

  • Hello Khalid,

    Thanks for our support and patience. Cx has responded:

    I am confused, maybe I have a bad datasheet.

    On the BQ25731 I think VSYS/VBAT is 2D/2C
    in the dump D540 is address 2F/2E manufacturing device and ID

    Since you want to see the A/D results I have added a 200 msec delay after the init before the register dump

    BQ Memory dump when REGN stays on, A/D works, bit 5 in 0x38 is 1

    00 3206 0000 36b0 09c4 3c00 0000 7300 2000
    10 ffff ffff ffff ffff ffff ffff ffff ffff
    20 0000 b880 2000 0f00 0000 0000 8281 d540
    30 3f00 00b7 0428 4a81 4020 205f 1848 006c

    BQ Memory dump when REGN goes off, A/D fails, bit 5 in 0x38 is 0

    00 3206 0000 36b0 09c4 3c00 0000 7300 2000
    10 ffff ffff ffff ffff ffff ffff ffff ffff
    20 0000 b800 2000 0000 0000 0000 0000 d540
    30 3f00 00b7 0428 4a09 4000 605f 1848 0004

    This unit currently has a 4S (max 16.8V) battery.

    Thank you.

    Regards,
    Archie A.

  • Hi Archie,

    2C/2D is correct, I had a typo in my response. I apologize for that.

    In first data dump, ADC Is working as expected and in second data dump, REGN has dropped out. Please clarify, did the customer write 0x38 bit to 5 to trigger this drop out? Please ask to monitor BAT voltage during this event to see if it is being overloaded.

    Thanks,

    Khalid

  • Hello Khalid,

    Thanks for clarifying.

    Yes, writing 0x38 bit 5 to 0 triggers this drop out. Cx shared the code.

    Note this happens only on a battery power up. If external power is supplied this does not happen.

    Thank you

    Regards,
    Archie A.

    /** @file Charger.c
       @brief This file contains the functions to control the power source and battery charging.
    
       The functions in this file communicate with the LTC1960 charger and power controller to, select power 
       source, set battery charging voltage and set battery charging current.
       @author Joseph Lehman
       @bug No known bugs.
     */
    #include "GenericTypeDefs.h"
    #include "Compiler.h"
    #include "peripheral\spi\plib_spi.h"
    #include "DiscreteIO.h"
    #include "Charger.h"
    #include "Timers.h"
    #include "AD.h"
    #include "app.h"
    #include "battery.h"
    #include "Fan.h"
    #include "Logging.h"
    #include "buzzer.h"
    #include "I2C.h"
    #include "BQ_Charger.h"
    
    
    typedef struct {
        uint16_t    status;
        uint16_t    option0;
        uint16_t    inCurrentLimit; // in ma
        uint16_t    vbus;           // in mv
    //    uint16_t    psys;           // in mv
        uint16_t    chargeCurrent;  // in ma
        uint16_t    dischargeCurrent; // in ma
        uint16_t    inCurrent;      // in ma
        uint16_t    inCurrentAvg;      // in ma
        uint16_t    vbat;           // in mv
        uint16_t    vsys;           // in mv
        uint8_t     manufacturID;
        uint8_t     deviceID;
    }BqInfo_t;
    
    BqInfo_t bqInfo;
    
    #define BQ_CHARGE_OPTION_0      0x00 
    #define  BQ_CHRG_OPT_0_EN_LPWR          0x8000
    #define  BQ_CHRG_OPT_0_WDTMR_ADJ_SEC    0x2000 // 0x6000 // wdt secs: 0 = off, 1 = 5, 2 = 88, 3 = 175 (POR default)
    #define  BQ_CHRG_OPT_0_IIN_DPM_AUTO_DISABLE 0x1000
    //#define  BQ_CHRG_OPT_0_OTG_ON_CHRGOK    0x0800
    #define  BQ_CHRG_OPT_0_EN_OOA           0x0400
    #define  BQ_CHRG_OPT_0_PWM_FREQ         0x0200
    #define  BQ_CHRG_OPT_0_LOW_PTM_RIPPLE   0x0100
    #define  BQ_CHRG_OPT_0_EN_CMP_LATCH     0x0080
    #define  BQ_CHRG_OPT_0_VSYS_UVP_ENZ     0x0040
    #define  BQ_CHRG_OPT_0_EN_LEARN         0x0020
    #define  BQ_CHRG_OPT_0_IADPT_GAIN       0x0010
    #define  BQ_CHRG_OPT_0_IBAT_GAIN        0x0008
    #define  BQ_CHRG_OPT_0_EN_LDO           0x0004
    #define  BQ_CHRG_OPT_0_EN_IIN_DPM       0x0002
    #define  BQ_CHRG_OPT_0_CHRG_INHIBIT     0x0001
    #define  BQ_CHRG_OPT_0_ADPT             (BQ_CHRG_OPT_0_WDTMR_ADJ_SEC | BQ_CHRG_OPT_0_IIN_DPM_AUTO_DISABLE | \
                                               BQ_CHRG_OPT_0_PWM_FREQ | BQ_CHRG_OPT_0_EN_LDO | BQ_CHRG_OPT_0_EN_IIN_DPM)
    #define  BQ_CHRG_OPT_0_BATT_SLEEP       (BQ_CHRG_OPT_0_EN_LPWR | BQ_CHRG_OPT_0_WDTMR_ADJ_SEC | BQ_CHRG_OPT_0_IIN_DPM_AUTO_DISABLE | \
                                               BQ_CHRG_OPT_0_PWM_FREQ | BQ_CHRG_OPT_0_EN_LDO | BQ_CHRG_OPT_0_EN_IIN_DPM)
    #define BQ_CHARGE_CURRENT_SET   0x02    // page 49 strange split of nibbles
    #define BQ_CHARGE_VOLTAGE_SET   0x04    // page 51
    #define BQ_VIN_MIN_SET          0x0A
    #define BQ_VSYS_MIN_SET         0x0C
    #define BQ_IIN_MAX_SET          0x0E
    #define BQ_CHARGER_STATUS       0x20
    #define  BQ_CHRG_STAT_STAT_AC           0x8000
    #define  BQ_CHRG_STAT_ICO_DONE          0x4000
    #define  BQ_CHRG_STAT_IN_VAP            0x2000
    #define  BQ_CHRG_STAT_IN_VINDPM         0x1000
    #define  BQ_CHRG_STAT_IN_IIN_DPM        0x0800
    #define  BQ_CHRG_STAT_IN_FCHRG          0x0400
    #define  BQ_CHRG_STAT_IN_PCHRG          0x0200
    #define  BQ_CHRG_STAT_IN_OTG            0x0100
    #define  BQ_CHRG_STAT_FAULT_ACOV        0x0080
    #define  BQ_CHRG_STAT_FAULT_BATOC       0x0040
    #define  BQ_CHRG_STAT_FAULT_ACOC        0x0020
    #define  BQ_CHRG_STAT_FAULT_SYSOVP      0x0010
    #define  BQ_CHRG_STAT_FAULT_VSYS_UVP    0x0008
    #define  BQ_CHRG_STAT_FAULT_FORCE_OFF   0x0004
    #define  BQ_CHRG_STAT_FAULT_OTG_OVP     0x0002
    #define  BQ_CHRG_STAT_FAULT_OTG_UVP     0x0001
    
    #define BQ_PROCHOT_STATUS       0x22
    #define BQ_IIN_DPM              0x24
    #define BQ_ADCVBUS_PSYS         0x26
    #define BQ_ADCIBAT              0x28
    #define BQ_ADCIIN_CMPIN         0x2A
    #define BQ_ADCVSYS_VBAT         0x2C
    #define BQ_IDS                  0x2E
    #define  BQ_MANUFACTURERID_DEVICE_ID    0x40
    #define BQ_CHARGE_OPTION_1      0x30
    #define BQ_CHARGE_OPTION_2      0x32
    #define BQ_CHARGE_OPTION_3      0x34
    #define  BQ_CHRG_OPT_3_DEFAULT          0x0428 
    #define  BQ_CHRG_OPT_3_RESET_REG        (0x4000 | BQ_CHRG_OPT_3_DEFAULT)
    #define BQ_PROCHOT_OPT_0        0x36
    #define BQ_PROCHOT_OPT_1        0x38
    #define  BQ_PROCHOT_OPT_1_DEFAULT 0x4020  // do not CLR bit 5 to 0 as this turns off the REGN for some reason when in battery mode.
    #define BQ_ADC_OPTION           0x3A
    #define  ADC_OPTION_CONFIG              0x605F
    #define BQ_CHARGE_OPTION_4      0x3C
    //#define  BQ_CHRG_OPT_4_DEFAULT          0x0048 // 0 frequency dithering, rest POR default. diterhing impacts conducted EMI??
    //#define  BQ_CHRG_OPT_4_DEFAULT          0x1048 // 2% frequency dithering, rest POR default. diterhing impacts conducted EMI??
    //#define  BQ_CHRG_OPT_4_DEFAULT          0x0848 // 4% frequency dithering, rest POR default. diterhing impacts conducted EMI??
    #define  BQ_CHRG_OPT_4_DEFAULT          0x1848 // 6% frequency dithering, rest POR default. diterhing impacts conducted EMI??
    #define BQ_VMIN_ACTIVE_PROTECTION 0x3E
    
    #define ADC_FULLSCALE   1
    
    
    void BqChargeCurrentSet(uint16_t milliamps) {
        uint16_t reg = ((milliamps / 2) + 0x20) & 0x1FC0; // round 
        I2cWriteBQWord(BQ_CHARGE_CURRENT_SET, reg);
    }
    
    void BqChargeVoltagetSet(uint16_t millivolts) {
        uint16_t reg = millivolts & 0x7FF8;
        I2cWriteBQWord(BQ_CHARGE_VOLTAGE_SET, reg);
    }
    
    bool BqIsCharging(void) {return ((bqInfo.status & (BQ_CHRG_STAT_IN_FCHRG | BQ_CHRG_STAT_IN_PCHRG)) != 0);}
    uint16_t BqVInGet(void) {return bqInfo.vbus;}
    uint16_t BqVbat(void) {return bqInfo.vbat;}
    uint16_t BqVsys(void) {return bqInfo.vsys;}
    uint16_t BqIin(void) {return bqInfo.inCurrentAvg;}
    
    bool BqHaveVbus(void) {return ((bqInfo.status & BQ_CHRG_STAT_STAT_AC) != 0 && bqInfo.vbus > 12000);}
    
    void BqIInMaxSet(uint16_t milliamps) {
        uint16_t reg = (milliamps / 100) << 8;
        I2cWriteBQWord(BQ_IIN_MAX_SET, reg);
    }
    
    void BqVInMinSet(uint16_t millivolts) {
        millivolts -= 3200;
        if (millivolts > 0x3FC0) millivolts = 0x3FC0;
        uint16_t vInMin = millivolts & 0x3FC0;  
        I2cWriteBQWord(BQ_VIN_MIN_SET, vInMin);
    }
    
    void BqVSysMinSet(uint16_t millivolts) {
        uint16_t vSysMin = (millivolts / 100) << 8;  
        I2cWriteBQWord(BQ_VSYS_MIN_SET, vSysMin);
    }
    
    void BqEnableLowPower(bool enableLowPower) {
        if (enableLowPower == TRUE) {
            if (I2cWriteBQWord(BQ_CHARGE_OPTION_0, BQ_CHRG_OPT_0_BATT_SLEEP) == TRUE) {
                bqInfo.option0 = BQ_CHRG_OPT_0_BATT_SLEEP;        
            }
        } else if (I2cWriteBQWord(BQ_CHARGE_OPTION_0, BQ_CHRG_OPT_0_ADPT) == TRUE) {
            bqInfo.option0 = BQ_CHRG_OPT_0_ADPT;
        }
    }
    
    bool BqInLowPower(void) { return (bqInfo.option0 & BQ_CHRG_OPT_0_EN_LPWR); }
    
    void BqRegDump(void) {
        uint16_t regBlock[8];
        uint16_t readAdr;
        
        for (readAdr = 0; readAdr < 0x40;) {
            I2cReadBQBlock(readAdr, regBlock, sizeof(regBlock));
            int i;
            PRINT("\r\n%2.2x", readAdr);
            for (i = 0; i < 8; ++i) {
                PRINT(" %4.4x", regBlock[i]);
            }
            readAdr += 16;
        }
        PRINT("\r\n");
        
    }
    
    void ChargerInit(void) {
        uint16_t temp;
        
        if (bqInfo.manufacturID != 0x40 && I2cReadBQWord(BQ_IDS, &temp) == true) {
            memset(&bqInfo, 0, sizeof(bqInfo));
            bqInfo.manufacturID = temp & 0xff; 
            bqInfo.deviceID = temp >> 8;
            if (bqInfo.manufacturID == 0x40) {
                //first time talking       
                I2cWriteBQWord(BQ_CHARGE_OPTION_3, BQ_CHRG_OPT_3_RESET_REG);
                DelayMs(10); //allow time for reset
                I2cWriteBQWord(BQ_CHARGE_OPTION_3, BQ_CHRG_OPT_3_DEFAULT);
                BqEnableLowPower(false);
                BqChargeVoltagetSet(DefaultChargeVoltage);
                BqVSysMinSet(DefaultVSysMin);
                BqVInMinSet(CarVoltageMin);
                I2cWriteBQWord(BQ_CHARGE_OPTION_4, BQ_CHRG_OPT_4_DEFAULT);   
                msecsLastScan = TimerMsecsGet();
                callNum = 0;
                I2cWriteBQWord(BQ_ADC_OPTION, ADC_OPTION_CONFIG);  
                I2cWriteBQWord(BQ_PROCHOT_OPT_1, BQ_PROCHOT_OPT_1_DEFAULT); //** changing BQ_PROCHOT_OPT_1_DEFAULT to 0x4000 disables REGN and A/D
            }
        }
        
        DelayMs(200);
        
        BqRegDump();
    }
    
    

  • Hi Archie,

    Thanks for the code shared. I don't see any issue with the coding and as mentioned before, I have tried to power up from Battery and disable the PP_ICRIT but I do not see the same issue.

    I have some more suggestions for things to try, however, I'd like to ask if the customer is using the PROCHOT function and how it is being used? Is the ICRIT critical for this application? This function monitors the Adapter current which is not valid when powering up from BAT.

    1. The reset value for ProchotOption1 is 41A0 and customer is setting it to 4020 (later 4000 since they have seen the issue). Does the issue occur when this register is also set to 4180 (i.e. ONLY turn off the PP_ICRIT bit and leave others the same as POR default)?

    2. As I mentioned before, can you please ask the customer to monitor (scope) VBAT, VSYS to see if there is any voltage dropout occurring during this code sequence?

    3. Is the PROCHOT low or high during this code sequence?

    Thanks,

    Khalid