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.

Programming the fuel gauge bq27542-G1 flash parameters

Other Parts Discussed in Thread: BQ27542-G1, BQSTUDIO

 am trying configure the bq27542-G1 fuel gauge flash parameters, Is there any alternate solution to configure those parameters without using any support tool(bqstudio) by means of programming directly from STM32 microcontroller.

 

As per the data sheet, to configure the fuel gauge flash required bqstudio tool  to access the fuel gauge flash (registers).

1). In that case bqstudio is required to configure fuel gauge for every board which uses the fuel gauge?

  • Hello Arunkumar,

    You can program the 542 DF with a micro using a set of extended commands to access the different subclass IDs and using I2C write transactions you can modify the contents. Please refer to section 5.1.1 of the TRM for more details. Also the app note SLUA467B discusses how to use I2C commands with the 542.

    Another option is to use bqStudio to generate a bqfs file which is a file format that is meant to be parsed by a micro that includes the I2C transactions to write the contents of the DF parameters you set in bqStudio. The app note SLUA541A discusses this format and how to use it.
  • Hello Fernando,

    Thanks for your reply. Here I have few doubts on accesing the Data Flash

    In discharging we are not obtaining correct StateOfCharge and TimeToEmpty.(Works fine in Charging mode).
    By referring to some of the TI forum's , we understood that some parameters like Design Capacity,Taper Voltage, AtRate Value,Terminate Voltage has to be set in the Gauge Flash.

    Notifying u that we don't have tools like : bqstudio and EVM KIT. We are directly Updating the flash using I2C Commands from the MCU.

    In order to change the Gauge flash parameters ,I am trying to change the sealed  mode to unsealed mode using the below code segment FYR,

    STM32_bq27542_cmdWrite(bq27542CMD_CNTL_LSB, 0x14);
    STM32_bq27542_cmdWrite(bq27542CMD_CNTL_MSB, 0x04);

    STM32_bq27542_cmdWrite(bq27542CMD_CNTL_LSB, 0x72);
    STM32_bq27542_cmdWrite(bq27542CMD_CNTL_MSB, 0x36);

    As per the TRM(SLUUB65A) page 60,sealed to unsealed default key is 0x36720414

    This makes the Gauge to unsealed mode. In unsealed mode, we updated desing Capacity to 2600. Later im updating the gauge to sealed mode and after sealing when i try to read the newly written design capacity, i still continue to get the default value(1000).

    Here to obtain the design capacity the I2C command is 0x3C and 0x3D as per the TRM, Page 82

    As per the TRM,Page 90, I am using subclass ID 48 and off set 12, by calculating i get the register address as 0x4C and 0x4D from where i try to read the deign capacity.

    Here which command i need to use to obtain the design capacity (0x3C and 0x3D or 0x4C and 0x4D).Please provide any sample code to update the required battery flash parameters without using any tool can through MCU


    Im pasting my code below .Please suggest me below code is it correct process to update the flash:

    STM32_bq27542_cmdWrite(bq27542CMD_CNTL_LSB, 0x14);
    STM32_bq27542_cmdWrite(bq27542CMD_CNTL_MSB, 0x04);

    STM32_bq27542_cmdWrite(bq27542CMD_CNTL_LSB, 0x72);
    STM32_bq27542_cmdWrite(bq27542CMD_CNTL_MSB, 0x36);

    /* Checking the Guage Unsealed */
    STM32_bq27542_read(0x01, 1, Control_Status_MSB);
    if(CHECK_BIT(Control_Status_MSB[0], 5))
    {
    printf("\r\t Fuel Guage In Sealed Mode \n");
    }
    else
    {
    printf("\r\t Fuel Guage In UnSealed Mode \n");

    STM32_bq27542_cmdWrite(bq27542CMD_DFDCNTL, 0);// BlockDataControl() = 0x00
    STM32_bq27542_cmdWrite(bq27542CMD_DFCLS, 48);// Write the subclass value
    STM32_bq27542_cmdWrite(bq27542CMD_DFBLK, 0);// Select offset within the flash

    STM32_bq27542_read(bq27542CMD_DFDCKS, 1, block_data_checksum_data); // Read Old CheckSum
    Old_Checksum = block_data_checksum_data[0];
    printf("\r\t Old_Checksum: %x \n",block_data_checksum_data[0]);

    STM32_bq27542_read(0x4D, 1, design_capacity_Data_LSB); // OLD_DesCap_LSB;
    STM32_bq27542_read(0x4C, 1, design_capacity_Data_MSB); // OLD_DesCap_MSB;

    printf("\r\t OLD_DesCap_MSB: %x OLD_DesCap_LSB: %x \n",design_capacity_Data_MSB[0],design_capacity_Data_LSB[0]);
    temData[0] = 0x28; //LSB
    temData[1] = 0x0A; //MSB

    for(i = 0;i<2;i++)
    {
    sum_cskm += temData[i];
    }

    printf("\r\t sum_cskm: %d \n",sum_cskm);

    STM32_bq27542_cmdWrite(bq27542CMD_DFDCKS, sum_cskm);// NEW_Cskm;

    STM32_bq27542_cmdWrite((bq27542CMD_ADF+0xD), temData[0]); //LSB
    STM32_bq27542_cmdWrite((bq27542CMD_ADF+0xC), temData[1]); //MSB

    STM32_bq27542_read(0x4D, 1, design_capacity_Data_LSB); // OLD_DesCap_LSB;
    STM32_bq27542_read(0x4C, 1, design_capacity_Data_MSB); // OLD_DesCap_MSB;

    if((design_capacity_Data_MSB[0] & temData[1]) && (design_capacity_Data_LSB[0] & temData[0]))
    {
    printf("\r\t New Value Updated: \n");
    printf("\r\t design_capacity_Data_MSB:%x \n",design_capacity_Data_MSB[0]);
    printf("\r\t temData[1]: %x\n",temData[1]);

    printf("\r\t design_capacity_Data_LSB:%x \n",design_capacity_Data_LSB[0]);
    printf("\r\t temData[0]: %x\n",temData[0]);

    }
    else
    {
    printf("\r\t New Value Not Updated: \n");
    }
    }
    /* Sealed */
    seal_data[0] = 0x00;
    seal_data[1] = 0x20;
    seal_data[2] = 0x00;

    STM32_bq27542_blockWrite(seal_data, 3);
    STM32_bq27542_read(0x01, 1, Control_Status_MSB);
    if(CHECK_BIT(Control_Status_MSB[0], 5))
    {
    printf("\r\t Fuel Guage In Sealed Mode \n");
    }
    else
    {
    printf("\r\t Fuel Guage In UnSealed Mode \n");
    }

    STM32_bq27542_read(0x4C, 2, ReadBuff);
    printf("\r\t ReadBuff[0]: %x\n",ReadBuff[0]);
    printf("\r\t ReadBuff[1]: %x\n",ReadBuff[1]);
    memset(&RxData,NULL,sizeof(ReadBuff));
    memcpy(RxData,ReadBuff,sizeof(ReadBuff));

    dcap = transBytes2UnsignedInt(RxData[0], RxData[1]);
    printf("\r\t New Design Capacity: %d\n",dcap);

  • hi ArunKumar,

    Pls update your device using the flash stream file formats.. i.e either bqfs or dffs. You will absolutely need bqstudio to extract these file formats after you have configured your gauge and carried out a learning cycle.

    See attached sample code for programming the device from your host uC. Also, during evaluation, Never seal your gauge. Sealing should only be done right before shipping the units.

    bq27500_flash_programmer_msp430.zip

  • Hi  Sir,

    Thanks for your kind reply. Im unable to unzip the file you have attached. It is prompting for password to unzip it. Can you please share me the password .

  • my apologies. The password is bms

    thanks
    Onyx