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.

BQ25180: BQ25180 always report 1 when powered by battery

Part Number: BQ25180

I had follow the tips of related previsious question (e2e.ti.com/.../bq25180-bq25180-not-exit-shipmode-with-button-press and i remove the diodes to push TSMR pin direct to ground when push-button is pressed.

Now, the circuit is according the following screenshot:

This is my current initialization function:

/**
 *
 */
static void BQ25180_SetDefaultConfiguration(void)
{  
    BQ25180_Register_VBAT_CTRL registerVBAT_CTRL;
    BQ25180_Register_ICHG_CTRL registerICHG_CTRL;
    BQ25180_Register_CHARGECTRL0 registerCHARGECTRL0;
    BQ25180_Register_CHARGECTRL1 registerCHARGECTRL1;
    BQ25180_Register_IC_CTRL registerIC_CTRL;
    BQ25180_Register_TMR_ILIM registerTMR_ILIM;
    BQ25180_Register_SHIP_RST registerSHIP_RST;
    BQ25180_Register_SYS_REG registerSYS_REG;
    BQ25180_Register_TS_CONTROL registerTS_CONTROL;
    BQ25180_Register_MASK_ID registerMASK_ID;  

    /* VBAT_CTRL Register */
    registerVBAT_CTRL.VBATREG = 0x46; //regulation in 4.2V | Battery Regulation Voltage VBATREG= 3.5V + VBATREG_CODE * 10mV
    BQ25180_WriteRegister(BQ25180_REGISTER_VBAT_CTRL, (uint8_t *)&registerVBAT_CTRL, sizeof(registerVBAT_CTRL));

    /* ICHG_CTRL Register */
    registerICHG_CTRL.CHG_DIS = 0b0; // Battery Charging Enabled
    registerICHG_CTRL.ICHG = 0b1111111; // Battery Charging programmable current = 1000mA
    BQ25180_WriteRegister(BQ25180_REGISTER_ICHG_CTRL, (uint8_t *)&registerICHG_CTRL, sizeof(registerICHG_CTRL));

    /* CHARGECTRL0 Register */    
    registerCHARGECTRL0.IPRECHG = 0b1; // Precharge is Term
    registerCHARGECTRL0.ITERM = 0b10; // Termination current = disable
    registerCHARGECTRL0.VINDPM = 0b11; // VINDPM Level Selection = Disable
    registerCHARGECTRL0.THERM_REG = 0b11; // Thermal Regulation Threshold = Disable
    BQ25180_WriteRegister(BQ25180_REGISTER_CHARGECTRL0, (uint8_t *)&registerCHARGECTRL0, sizeof(registerCHARGECTRL0));

    /* CHARGECTRL1 Register */
    registerCHARGECTRL1.IBAT_OCP = 0b11; // Battery Discharge Current Limit = Disable
    registerCHARGECTRL1.BUVLO = 0b011; // Battery Undervoltage LockOut Falling Threshold = 2.8V
    registerCHARGECTRL1.CHG_STATUS_INT_MASK = 0b1; // Disable Charging Status Interrupt
    registerCHARGECTRL1.ILIM_INT_MASK = 0b1; // Disable ILIM Fault Interrupt
    registerCHARGECTRL1.VDPM_INT_MASK = 0b1; // Disable VINDPM and VDPPM Interrupt
    BQ25180_WriteRegister(BQ25180_REGISTER_CHARGECTRL1, (uint8_t *)&registerCHARGECTRL1, sizeof(registerCHARGECTRL1));

    /* IC_CTRL Register */   
    registerIC_CTRL.TS_EN = 0b0; // TS Auto Function = Disable
    registerIC_CTRL.VLOWV_SEL = 0b0; // Precharge Voltage Threshold (VLOWV) = 3V
    registerIC_CTRL.VRCH_0 = 0b0; // Recharge Voltage Threshold = 100mV
    registerIC_CTRL.TMRSLW_EN = 0b0; // Timer Slow = The timer is not slowed at any time
    registerIC_CTRL.SAFETY_TIMER = 0b11; // Disable safety timer
    registerIC_CTRL.WATCHDOG_SEL = 0b11; // Disable watchdog function
    BQ25180_WriteRegister(BQ25180_REGISTER_IC_CTRL, (uint8_t *)&registerIC_CTRL, sizeof(registerIC_CTRL));

    /* TMR_ILIM Register */
    registerTMR_ILIM.MR_LPRESS = 0b00; // Push button Long Press duration timer 5s
    registerTMR_ILIM.MR_RESET_VIN = 0b0; // Hardware reset condition = Reset sent when long press duration is met
    registerTMR_ILIM.AUTOWAKE = 0b01; // Auto Wake Up Timer Restart = 1s
    registerTMR_ILIM.ILIM = 0b111; // Input Current Limit Setting = 1100mA
    BQ25180_WriteRegister(BQ25180_REGISTER_TMR_ILIM, (uint8_t *)&registerTMR_ILIM, sizeof(registerTMR_ILIM));

    /* SHIP_RST Register */ 
    registerSHIP_RST.REG_RST = 0b0; // Software Reset = Do nothing
    registerSHIP_RST.EN_RST_SHIP = 0b00; // Shipmode Enable and Hardware Reset = Do nothing
    registerSHIP_RST.PB_LPRESS_ACTION = 0b00; // Pushbutton long press action = Do nothing
    registerSHIP_RST.WAKE1_TMR = 0b00; // Wake 1 Timer Set = 300ms
    registerSHIP_RST.WAKE2_TMR = 0b00; // Wake 2 Timer Set = 2s
    registerSHIP_RST.EN_PUSH = 0b1; // ERRATA: https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1291241/bq25180-en_push-register-doesn-t-seem-to-work-as-described?tisearch=e2e-sitesearch&keymatch=bq25180# Enable Push Button and Reset Function on Battery Only
    BQ25180_WriteRegister(BQ25180_REGISTER_SHIP_RST, (uint8_t *)&registerSHIP_RST, sizeof(registerSHIP_RST));
    
    BQ25180_ReadRegister(BQ25180_REGISTER_SHIP_RST, (uint8_t *)&registerSHIP_RST, sizeof(registerSHIP_RST));

    ESP_LOGW(TAG, "registerSHIP_RST.EN_PUSH = %d", registerSHIP_RST.EN_PUSH);

    /* SYS_REG Register */ 
    registerSYS_REG.SYS_REG_CTRL = 0b111; // SYS Regulation Voltgage = Pass-Through (VSYS is VIN)
    registerSYS_REG.SYS_MODE = 0b00; // SYS powered from VIN if present or VBAT
    registerSYS_REG.WATCHDOG_15S_ENABLE = 0b00; // I2C Watchdog = Disable
    registerSYS_REG.VDPPM_DIS = 0b0; // Enable VDPPM
    BQ25180_WriteRegister(BQ25180_REGISTER_SYS_REG, (uint8_t *)&registerSYS_REG, sizeof(registerSYS_REG));

    /* TS_CONTROL Register */
    registerTS_CONTROL.TS_HOT = 0b00; // TS Hot threshold register = 60°C
    registerTS_CONTROL.TS_COLD = 0b00; // TS Cold threshold register = 0°C
    registerTS_CONTROL.TS_WARM = 0b1; // TS Warm threshold = Disabled
    registerTS_CONTROL.TS_COOL = 0b1; // TS Cool threshold register = Disabled
    registerTS_CONTROL.TS_ICHG = 0b0; // Fast charge current when decreased by TS function = 0.5*ICHG
    registerTS_CONTROL.TS_VRCG = 0b0; // Reduced target battery voltage during Warm = VBATREG -100mV
    BQ25180_WriteRegister(BQ25180_REGISTER_TS_CONTROL, (uint8_t *)&registerTS_CONTROL, sizeof(registerTS_CONTROL));

    /* MASK_ID Register */
    registerMASK_ID.TS_INT_MASK = 0b1; // Mask TS Interrupt
    registerMASK_ID.TREG_INT_MASK = 0b1; // Mask TREG Interrupt
    registerMASK_ID.BAT_INT_MASK = 0b1; // Mask BOCP and BUVLO Interrupt
    registerMASK_ID.PG_INT_MASK = 0b1; // Mask PG and VINOVP Interrupt
    BQ25180_WriteRegister(BQ25180_REGISTER_MASK_ID, (uint8_t *)&registerMASK_ID, sizeof(registerMASK_ID));

    ESP_LOGI(TAG, "Registers defined to custom configuration!");

}

I reading the TSMR pin state with this function:

/**
 *
 */
bool BQ25180_GetTSMR(void) {
    
    BQ25180_Register_STAT0 registerSTAT0;

    BQ25180_ReadRegister(BQ25180_REGISTER_STAT0, (uint8_t *)&registerSTAT0, sizeof(registerSTAT0));

    ESP_LOGW(TAG, "TSMR Status %d", !registerSTAT0.TS_OPEN_STAT);
    
    return !registerSTAT0.TS_OPEN_STAT;
}

The expected behavior is when pressed the function return 1 (true).

I read the state of TSMR when VBUS is connected and have worked fine as expected (return 0 when not pressed the button and 1 when pressed), but when powered just by battery the state of TSMR is always return 1.

Why the  reason for this behavior?

  • Hi Gustavo,

    Can you please clarify how the state of the TSMR is read? Is an MCU pin connected to TSMR as to read the voltage level of the pin?

    If so the possible explanation may be related to how TS/MR behavior differs in Charge mode vs Battery only mode. When VIN is present the pin is constantly biased to monitor the TS voltage so the voltage is typically high there. While in BAT only mode the TSMR is only biased in pulses in order to minimize current consumption, these pulses are used to determine when MR is pressed. This means the average voltage is very low so sampling it will most likely indicate a low voltage on the pin at this time.

    Below shows the difference between VIN present (charge mode) and battery only mode for BAT.

    Best Regards,

    Juan Ospina

  • Are possibel put a pull-up from vsys to bias the TSMR?. I read this signal using a GPIO.

  • What's the suggestion to read the TSMR pin state when powered from battery?

  • A pull up to SYS may help in raising the average voltage, but I would keep in mind that it's likely to increase current consumption while in BAT mode and charger mode. Additionally, it will definitely have an effect on TS behavior while charging, based on your schematic I'm assuming its not being used so I'd recommend disabling it via I2C.

    An alternative would be to make your TS/MR read function interrupt driven. Since there is no DC high voltage with this pulsing, you can try to detect the voltage edges on the GPIO pin by making it generate an edge triggered interrupt. Though in this case you would be looking for missing edges since the MR press results in no pulses being shown.

    Alternatively, you can use the twake1 interrupts to indicate to you that the button has been pressed and use the detected pulses to indicate that the button is released.

    Best Regards.

  • I do a mistake. I reading the signal using a I2C bus by STAT0 register (TS OPEN).

    I will try use the pull-up to solve thi question.

    I reply here if ok.

    Thanks! 

  • Not working. Some alternative to read STAT0 register (TS OPEN) when powered by battery?

  • Hi Gustavo,

    Can you please clarify what you mean?

    Best Regards,

    Juan Ospina

  • I think I wasn't clear on my needs.

    I am using the TSMR pin as a digital input to read the button state of the circuit I provided above. The button just shorts to 0V.

    I want to read the state of the TSMR pin through the STAT0 register (TS OPEN).

    When connected to an external source, the BQ25180 works perfectly, but when the BQ25180 powered only by the battery always reports the same value, there is no difference whether the button is pressed or not.

    Apparently there is a change in the TSMR pin logic that does not allow it to be used in this way.

    Could you confirm if it would be possible to use it as I suggested above or is there any limitation?

  • Ah thank you for clarifying. Using it in the way you are describing (leveraging TS monitoring to report when the button is pressed) will work fine while VIN is connected, but TS sensing is disabled once VIN is disconnected. This is because TS is only used to control charging which won't take place without VIN present, so to minimize current consumption it is disabled.

    This means that while VIN is not present the TS_OPEN status bit will not accurately reflect the voltage present so you won't be able to use it to detect MR presses.

    Best Regards.