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.

BQ27742-G1: Command Codes

Part Number: BQ27742-G1

The I2C syntax is unclear to me in the datasheet:

https://www.ti.com/lit/ds/symlink/bq27742-g1.pdf?ts=1611584050250&ref_url=https%253A%252F%252Fwww.google.com%252F

There are "Command Codes" (Table 8) which are of the syntax "0x00 and 0x01", then there are "Subcommand Codes" of syntax "0x0000". In Section 7.6.2 I2C Interface, (Figure 16.c) it shows only an 8 bit CMD[7:0] for a 1-byte read.

How are we actually supposed to implement the Command Codes? Are the two bytes supposed to be separated by an Acknowledge, or just write all 16 bits at once? I.e.

Option 1:

Option2:

Or have I misunderstood this all together?

What about for the subcommands? Would you just extend the CMD sections of Option 1 or 2 to contain 4 bytes?

Also, I was reading elsewhere about some people having issues with endiness here. Could you clarify how you would read the Temperature (i.e. command code 0x06, and 0x07) in addition to how you would read the HW_VERSION (i.e. subcommand 0x0003?

Assuming Option 1, would these be

  1. [S][1010101][0][A][0x06][A][0x07][A][Sr][1010101][1][A][DATA[0:7][N][P]
  2. [S][1010101][0][A][0x00][A][0x01][A][0x00][A][0x03][A][Sr][1010101][1][A][DATA[0:7][N][P]

?

  • There is an ACK after every byte.

    The command is always 1 byte (0x06) for temperature. It is equivalent to memory address 0x06 in I2C used with EPROM devices. this gives LSB

    After reading one byte, you can continue reading another byte to get MSB. Or you can read separately from command 0x07 to get the MSB.

  • Thanks Shirish.

    I think I understand for the Standard Data Commands. So for temperature I could use:

    with CMD being simply 0x06, and the two DATA bytes will represent the LSB and MSB respectively due to the internal address pointer incrementing during quick reads?

    Or I could do two of these:

    with CMD being 0x06 the first time around and 0x07 the 2nd time around. Did I understand that correctly?

    The datasheet also mentions "Quick writes function in the same manner and are a convenient means of sending multiple bytes to consecutive command locations (such as two-byte commands that require two bytes of data)." but I'm not seeing an example of using this for two-byte commands. How would this look like?

    Maybe I have misunderstood, but based on your explanation, I'd think something like this would not work:


    How then can we use quick writes as a means of executing two-byte commands? Do these only work for write operations?

    I think this and my other question about Sub Commands would be cleared up if someone could give the sequence for reading the HW_VERSION as an example.

    I assume what I proposed before would not work:
    [S] [10101010][A] [0x00][A] [0x01][A] [0x00][A] [0x03][A] [Sr] [10101011][A] DATA[0:7][N][P]

    Or would it work? Is the HW_VERSION a 2-byte value or just the subcommand code to read a 1-byte value?

  • Hello Christopher,

    You understood correctly for the read.

    To read hardware version you will send the 2 bytes 0x01 0x00 right after the command 0x00, then send stop

    Follow this up with a separate read 2 bytes using command 0x00

  • Thank you for confirming Shirish. I understand the read operation for the Standard Commands now.

    I still don't I understand the HW_VERSION example for the subcommands though.

    the 2 bytes 0x01 0x00

    This is the "Control()" Standard Command with LSB first I presume.

    the command 0x00

    I'm not sure what this is supposed to be. What is the "command 0x00"? I'm not seeing any such single-byte command in the datasheet. 

    Also I'm not seeing where you are specifying the 0x0003 SUBCOMMAND CODE, so I don't know how this would differentiate between FW_VERSION or any other SUBCOMMAND.

    Best regards,
    Christopher

  • Hello Christopher,

    The commands are not explained in detail in the datasheet, the TRM should be referenced for this.

    What Shirish is saying is input 0x00 in the command or starting address section, then you send the command itself, then you must read back from the same "control()" register.

    Sincerely,

    Wyatt Keller