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.

Unable to read control commands on the BQ27742-G1

Other Parts Discussed in Thread: BQ27742-G1

Hi, I'm writing a library for the BQ27742-G1 fuel gauge, I don't have any problem at all when reading standard commands like Voltage(), Temperature(), etc. but I'm being unable to read back control commands like HW_VERSION, FW_VERSION, etc. Most likely I'm doing something wrong. 

For reference, this is what I do to retrieve HW_VERSION:

Issuing the command and subcommand:

- Write: address | 0x00 | 0x00 | 0x02 | STOP 

Write control address to read the results

- Write: address | 0x00

Then I read back 2 bytes (for 0x00 and 0x01) but I'm always getting 0x8018 as a result, no matter what subcommand I write. I also noted that If I read the control register without issuing any previous command I get the same value (0x8018).

Any help would be greatly appreciated.

Thanks

EDIT: I detached and attached again the battery from the fuel gauge board and now I'm getting 0x0008 instead, no matter what subcommand I write. 

  • Okay, I found the problem by looking to the SLUA467B document. The subcommand must be sent inverted: the LSB first and then the MSB. So instead of writing 0x00, 0x00, 0x02 it should be 0x00, 0x02, 0x00.

    AFAIK this is not specified on the datasheet, I suggest to add this information on the next revision.
  • Hi Adria,
    The commands always have to be in little endian format (that is LSB and MSB like you pointed out) . This is applicable to all our gauges and I believe is standard practice for most devices using I2C protocol.