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.

BQ35100: Inconsistent command behavior to ManufacturerAccessControl

Part Number: BQ35100
Other Parts Discussed in Thread: BQSTUDIO

I am just starting to work with the BQ35100 and am trying to get several pieces of data off of the gauge to make sure I can read information correctly.

Some of the data I am trying to get off the device are: device type, operation config A, device name, and control status. I'm programming a host MCU to communicate with the BQ35100 and right now that's the only interface I have with the gauge.

I have a couple of wrapper functions to facilitate the i2c communications:

i2c_wrapper_write(uint8_t address, uint8_t *data, uint8_t data_length, bool send_stop);
i2c_wrapper_read(uint8_t address, uint8_t *data, uint8_t data_length);

Now to grab device type I would do the following (assume some uint16_t called data exists):

i2c_wrapper_write(0x55, {0x3e, 0x01, 0x00}, 3, true); // set MAC command to 0x0001
i2c_wrapper_write(0x55, {0x40}, 1, false); // Set address to MACData
i2c_wrapper_read(0x55, (uint8_t*)&data, 2); // Read back into data variable

data now correctly has 0x100.

Next for operation config A I would do the following:

i2c_wrapper_write(0x55, {0x3e, 0xb1, 0x41}, 3, true); // Set command to operation config A
i2c_wrapper_write(0x55, {0x40}, 1, false); // Set address to MACData
i2c_wrapper_read(0x55, &cfg, 1); // Read data into cfg variable

cfg now strangely has 0xf3. I see that the default value for 0x41b2 (alert config) is 0xf3 so I assume its reading that?

Instead I now have to issue another write/read to 0x40 to get 0x80 (expected default config).

Similarly to get the device name (expected bq35100) I would do the following:

i2c_wrapper_write(0x55, {0x3e, 0x60, 0x40}, 3, true); // Set command to get device name
i2c_wrapper_write(0x55, {0x40}, 1, false); // Set address to MACData
i2c_wrapper_read(0x55, &name, 7); // Expect 7 chars for bq35100

Now this correctly populates name with: {0x62, 0x71, 0x33, 0x35, 0x31, 0x30, 0x30} (bq35100 in ascii).

However, if I try the same procedure that I did for the operation config A (issuing another write/read to 0x40) name instead now has {0x07, 0x62, 0x71, 0x33, 0x35, 0x31, 0x30}. I would need to do an 8 byte read to get the last ASCII "0". I am not sure why the first byte is now suddenly 0x07.

Finally to get control status I do the following:

i2c_wrapper_write(0x55, {0x00}, 1, true); // set address to control
i2c_wrapper_read(0x55, (uint8_t*)&status, 2); // read back register data

This gives me back 0x2080 which should be expected (INITCOMP set and security mode in FULL ACCESS).
I would also expect to be able to do the following to grab control status:

i2c_wrapper_write(0x55, {0x3e, 0x00, 0x00}, 3, true); // Set command to get control status
i2c_wrapper_write(0x55, {0x40}, 1, false); // Set address to MACData
i2c_wrapper_read(0x55, (uint8_t*)&status, 2);

I'm basically sending the 0x0000 command to MAC and then reading the data from MACData. This instead populates status with 0xf340 and I'm not sure where that comes from. Doing a reread doesn't change much.

I've also tried reading more bytes, starting from 0x3e to be able to verify the command (2 bytes should give me the active command) but it is also inconsistent between commands.

As an example for operation config A:

i2c_wrapper_write(0x55, {0x3e, 0b1, 0x41}, 3, true); // set command to op config a
i2c_wrapper_write(0x55, {0x3e}, 1, false); // set addr to MAC (to be able to read back command)
i2c_wrapper_read(0x55, (uint8_t*)&cmd, 2); // expect 0x41b1 (actually getting 0x09f3)
i2c_wrapper_write(0x55, {0x3e}, 1, false); // set addr to MAC (to be able to read back command)
i2c_wrapper_read(0x55, (uint8_t*)&cmd, 2); // expect 0x41b1 (now correctly getting 0x41b1)

I've been using the following 3 docs in my development: i2c reference, technical reference, data sheet.

Could I get some clarification around what's expected behavior regarding these commands (and others).

  • Unfortunately, we cannot debug your code.  I would suggest you take a look at the following app note and also make good use of the Advanced Comm I2C windows in the bqStudio.

     

    Andy

  • Thanks Andy. I was able to get access to a evaluation module and use bqstudio to debug some more, instead of programming my host MCU. This has answered some of my questions.

    However I have a couplemore  questions after playing around with bqstudio a little:

    I am still seeing 0x7 after querying the device name. I assume this is expected now but was just curious why this would happen.

    See the third byte in the transaction log below:

    Second question is around setting operation config A. I followed the example in figure 12 here to try and set operation config A to 0x82. I'm not sure why we have to add 4 to the length. I didn't see anything in the technical reference that mentions anything about this. Is it consistent that I would have to add 4 to the length of data I write to MACData and then write that to MACDataLen?

    Thanks,

    Gautam

  • Hi Gautam,

    See my comments below.

    I am still seeing 0x7 after querying the device name. I assume this is expected now but was just curious why this would happen.

    [Andy] 0x07 is the total length of the device name.  The actual device name is "bq35100" (62 71 33 35 31 30 30). 

    Second question is around setting operation config A. I followed the example in figure 12 here to try and set operation config A to 0x82. I'm not sure why we have to add 4 to the length. I didn't see anything in the technical reference that mentions anything about this. Is it consistent that I would have to add 4 to the length of data I write to MACData and then write that to MACDataLen?

    [Andy]  Can you send me the transaction log so that I can see all the commands you send to the gague?

    Andy

  • Hi Andy,

    Thanks for clarifying the first byte of the name! It wasn't clear from the doc but it makes sense to provide the length of the string.

    As for operation config A here is a log of what I am doing; I'm basically following figure 12 here.

    The part I'm confused about is why we have to write 0x05 to 0x61 (the fifth transaction I do). According to the technical reference (relevant section below) I need to provide to MACDataLen the length of MacData that is used to compute the checksum.

    Now the checksum that was computed was done using only a single data byte (0x82 from the third transaction in my screenshot). Why do I have to add 4 to the length? It seems to be required as it worked and was done so in figure 12 of the i2c reference.

    Thanks,

    Gautam

  • Hi Gautam,
    MACDataLen should be the total number of bytes written including the MAC address (2 bytes), data bytes, checksum(1 byte), and MACDataLen itself (1 byte). 
    That's why we mentioned in the app note that the Length of Data Written is set to the number of bytes + 4.
    Andy
  • Thank you for answering my questions!