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.

[FAQ] BQSTUDIO: How do I interpret the lines in a bq.fs / df.fs file for use with my I2C or HDQ gauge?

Part Number: BQSTUDIO

I generated a bq.fs and df.fs file using Battery Management Studio (bqStudio) for my I2C/HDQ gas gauge. TI documentation indicates that this file may be used by the host processor to update the gas gauge. What is the format of this file and how do I use it?

  • Flash Stream File Format for I2C / HDQ

    1.   Introduction

    The following sections describe the file format for the TI BMS FlashStream files for I2C or HDQ. Examples of Flashstream files include bq.fs, df.fs and gm.fs files. These files contain instructions for I2C or HDQ operations required for updating a device’s instruction flash (IF) or data flash (DF). The only difference between the I2C commands and the HDQ commands is that the HDQ commands do not include the i2cAddr parameters. Unless noted otherwise, this document references the I2C commands. To determine the corresponding HDQ commands, simply remove the i2cAddr parameter if present.

    2.   File Structure

    The Flashstream file is an ASCII text file which contains both commands and data.  Each line of the file represents one command and potentially XX bytes of data, as described below.  No line will contain more than 96 data bytes.  The first two characters of each line represent the command, followed by a “:”.

     

    “W:” – indicates the line is a command to write one or more bytes of data.

    “C:” – indicates the line is a command to read and compare one or more bytes of data.

    “X:” – indicates the line is a command to wait a given number of milliseconds before proceeding.

     

    White space is used to separate fields within the Flashstream file.  Each line contains one and only one of the above commands.

    3.   Write Command

    The write command “W:” instructs the host to write one or more bytes to a given I2C address and given register address.  The format of this sequence is:

     

    “W: i2cAddr RegAddr Byte0 Byte1 Byte2…”.

     

    For example, the following:

     

    W: AA 55 AB CD EF 00

     

    indicates that the host should write the byte sequence 0xAB 0xCD 0xEF 0x00 to register 0x55 of the device addressed at 0xAA.

     

    Or more precisely, it indicates to write the following data to the device address 0xAA:

    0xAB to register 0x55

    0xCD to register 0x56

    0xEF to register 0x57

    0x00 to register 0x58

     

    4.   Read and Compare Command

    The read and compare command is formatted identically to the write command.  The data presented with this command should match the data read exactly, or the operation should cease with and error indication to the user.  The format of this sequence is:

    “C: i2cAddr RegAddr Byte0 Byte1 Byte2…”.

     

    The byte sequence Byte0 through ByteN are the bytes to be matched.

    The number of bytes to be read is the number of bytes to match. The “C:” instructs the host to read a given number of bytes from a given I2C address and given register address and compare the read bytes with the bytes that follow RegAddr.

     

    An example of this command is as follows:

     

    C: AA 55 AB CD EF 00

     

    indicates that the host should read 4 bytes from register 0x55 of the device addressed at 0xAA and compare the read byte sequence with the byte sequence 0xAB 0xCD 0xEF 0x00

     

    Or more precisely, it indicates to read and compare the following data from the device address 0xAA:

    0xAB should equal the value read from register 0x55

    0xCD should equal the value read from register 0x56

    0xEF should equal the value read from register 0x57

    0x00 should equal the value read from register 0x58

     

    5.   The Wait Command

    The wait command indicates that the host should wait a minimum of the given number of milliseconds before continuing to the next row of the flash stream.  For example, the following:

     

    X: 200

     

    indicates that the host must wait at least 200ms before continuing.

     

    Note: The number that follows “X:” is a decimal number. This is different from all other commands. In general all bytes are specified as a hexadecimal value except in this command..