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.

Linux: BQ27220: cannot config BQ27220 based on TI Gauge Communication source code slua801.pdf

Other Parts Discussed in Thread: BQ27220

Tool/software: Linux

Hi Experts,

I try to set some registers to achieve lowest power consumption in BQ27220 based on TI Gauge Communication source code (slua801.pdf) :
-) Set Dsg Relax Time to zero (0x922E)
-) disable the wake comparator (Operation Config A [WAKE_EN, WK_TH0, WK_TH1] all zero) (0x9206)


I reference to BQ27220: Configuration not changed in device  e2e.ti.com/.../2331011
but I still cannot write/update BQ27220 configurations.
Would anyone plz check below process (or attached file function BQ27220_12()) and give me advice how to achieve correct command flow.

note: attached file is based on TI Gauge Communication source code (slua801.pdf). but seems it cannot be used for BQ27220 directly???

thanks.

==============

// try example in BQ27220: Configuration not changed in device
//OperationStatus: 0x(94), Bit 2 CFGUPDATE=0
//0x929F MACData(0X40 0x41) = 0xB80B = 3000 mAh
//ENTER_CGF_UPDATE
nResult = gauge_control(pHandle, 0x0090);
sleep(2);
//OperationStatus: 0x(494), Bit 2 CFGUPDATE=1
//ref to e2e.ti.com/.../2331011
BQ27220_WriteByte(0x3E,0x9f); // design capacity address: 0x929F
BQ27220_WriteByte(0x3F,0x92);
BQ27220_WriteByte(0x40,0x0f); // design capacity = 0x0FCB
BQ27220_WriteByte(0x41,0xcb); //
BQ27220_WriteByte(0x60,0xf4); // 0x9F + 0x92 + 0x0F + 0xCB = 0x020B. 0x020B OR 0xFF = 0x0B. CS = 0xFF - 0x0B = 0xF4
BQ27220_WriteByte(0x61,0x06); // len
//EXIT_CFGUPDATE
nResult = gauge_control(pHandle, 0x0092);
sleep(2);
//OperationStatus: 0x(94), Bit 2 CFGUPDATE=0
//0x929F MACData(0X40 0x41) = 0xB80B = 3000 mAh, did not change.
==============
==============
// want to set Discharge Relax Time (0x922E) to 0
//OperationStatus: 0x(94), Bit 2 CFGUPDATE=0
//0x922E MACData(0X40 0x41) = 0x3C00 = 60 s
//ENTER_CGF_UPDATE
nResult = gauge_control(pHandle, 0x0090);
sleep(2);
//OperationStatus: 0x(494), Bit 2 CFGUPDATE=1
//ref to e2e.ti.com/.../2331011
BQ27220_WriteByte(0x3E,0x2E);
BQ27220_WriteByte(0x3F,0x92);
BQ27220_WriteByte(0x40,0x00);
BQ27220_WriteByte(0x41,0x00);
BQ27220_WriteByte(0x60,0x3F); // 0xFF - ( 0x2e + 0x92 + 0x00 + 0x00 ) OR 0XFF = 0x3F
BQ27220_WriteByte(0x61,0x06);
//EXIT_CFGUPDATE
nResult = gauge_control(pHandle, 0x0092);
sleep(2);
//OperationStatus: 0x(94), Bit 2 CFGUPDATE=0
//0x922E MACData(0X40 0x41) = 0x3C00 = 60 s, did not change
==============

ref to: BQ27220: Configuration not changed in device 

thanks

HB

  • Hi hb,
    We will review this and get back to you on or before Wednesday.
    thanks
    Onyx
  • Your sequence looks correct.

    Please read the checksum and length after your write it. Try to add a delay between writing to 0x61 and issuing the EXIT_CFGUPDATE command.

    Do you get any unexpected NACKs when writing? Can you record the actual signals on the I2C bus?

  • Hi all,

    after try and error, I need to add many delay to set configs ..
    many someone knows how to reduce delay.

    printf(" ============== \n\r");
    printf(" ENTER_CGF_UPDATE \n\r");
    nResult = gauge_control(pHandle, 0x0090);
    sleep(2);
    battVolLB = BQ27220_ReadByte(0x3A);
    battVolHB = BQ27220_ReadByte(0x3B);
    battVoltDig = (uint32_t)(battVolHB*256) + (uint32_t)battVolLB;
    printf(" \t OperationStatus: (%d) 0x(%x) \n\r",battVoltDig,battVoltDig);
    //==================================
    BQ27220_WriteByte(0x3E,0x2E);
    sleep(1);
    BQ27220_WriteByte(0x3F,0x92);
    sleep(1);
    BQ27220_WriteByte(0x40,0x00);
    sleep(1);
    BQ27220_WriteByte(0x41,0x00);
    sleep(1);
    BQ27220_WriteByte(0x60,0x3F); // 0xFF - ( 0x2e + 0x92 + 0x00 + 0x00 ) OR 0XFF = 0x3F
    sleep(1);
    BQ27220_WriteByte(0x61,0x06);
    sleep(1);
    nResult = gauge_cmd_read(pHandle, 0X60);
    printf(" \t gauge_cmd_read checksum(0x60) = 0x%04X \n\r", nResult);
    sleep(1);
    //==================================
    printf(" EXIT_CFGUPDATE \n\r");
    nResult = gauge_control(pHandle, 0x0092);
    //==================================


    HB