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.

BQ34Z110: bq34z110PWR Write Data Flash Process

Part Number: BQ34Z110
Other Parts Discussed in Thread: BQ34Z100, BQSTUDIO
Hi,
What are the correct steps to update/change the value in the data flash for BQ34Z110 IC? 
For example, we are changing the value of Design Capacity from 4000 to 16000 (mAh). The way we are doing right now:
1. unseal
2. read data block
3. change register and write it back
4. checksum
5. read data block to confirm change
We have been referring to the library from Github. For this specific task, we use this line of code.
The problem is the library was for BQ34Z100 and we are using BQ34Z110. And until now we still can't manage to change the value on the data flash but were able to read from the data flash.
Is there anything we should have done differently for the BQ34Z110? Is there any difference in the process to write the flash data between BQ34Z100 and BQ34Z110? 
  • Hello Nur,

    The process is the same for both. The block sizes and offset are likely to be different. The TRM has an example sequence for reference.

  • Hi Shirish,

    I do exactly as in document SLUA790 pg.8 (code below). But still unable to write to the flash. Is there any problem with my code?

    Aside from the code, is the IC needed to be in Normal mode for the writing process to execute?

    Because, I checked the CONTROL_STATUS and the bit for SLEEP mode was set to 1, which means the IC is in Sleep mode.

    Do I need to set the IC to Normal mode first before I can write something to the IC?

    /* To write 16000 to the Design Capacity on the data flash replacing the
    default value 4000*/
    uint8_t subclass = 48; //or 0x30
    uint8_t offset = 21; //or 0x15
    uint16_t value = 16000;
    
    const uint8_t BQ34Z110_ADDRESS = 0x55;
    uint8_t flash_block_data[32] = {0};
    
    
      /*
      Unsealed
      */
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x00);
      Wire.write(0x14);
      Wire.write(0x04);
      Wire.endTransmission();
      
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x00);
      Wire.write(0x72);
      Wire.write(0x36);
      Wire.endTransmission();
    
      delay(4000); // mandatory wait time after unseal
    
      /*
      Reading the data flash
      */
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x61); // BlockDataControl()
      Wire.write(0x00);
      Wire.endTransmission();
    
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x3e); // DataFlashClass()
      Wire.write(subclass); // Subclass 48 = 0x30
      Wire.endTransmission();
    
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x3f); // DataFlashBlock()
      Wire.write(offset / 32); // 21/32 = 0x00
      Wire.endTransmission();
      
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x40); // BlockData()
      Wire.endTransmission();
      Wire.requestFrom(BQ34Z110_ADDRESS, 32, true);
      Wire.readBytes(flash_block_data, 32); // read 32 bytes
    
      /*
      Checksum
      */
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x60); // BlockDataCheckSum()
      Wire.write(0x00);
      Wire.endTransmission();
    
      /*
      Update block data
      */
      flash_block_data[offset] = value >> 8;
      flash_block_data[offset + 1] = value & 0xff;
    
      /*
      Writing the data flash 
      */
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x3e); // DataFlashClass()
      Wire.write(subclass); // Subclass 48 = 0x30
      Wire.endTransmission();
    
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x3f); // DataFlashBlock()
      Wire.write(offset / 32); // 21/32 = 0x00
      Wire.endTransmission();
    
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x40); //BlockData()
      Wire.write(flash_block_data, 32); // write 32 bytes
      Wire.endTransmission();
    
      /*
      Checksum
      */
      uint8_t chksum = flash_block_checksum();
      uint8_t chksum2 = flash_block_checksum_2();
    
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x60); // BlockDataCheckSum()
      Wire.write(chksum);
      Wire.endTransmission();
    
      delay(5000);
    
      /*
      Reading the data flash
      */
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x61); // BlockDataControl()
      Wire.write(0x00);
      Wire.endTransmission();
    
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x3e); // DataFlashClass()
      Wire.write(subclass); // Subclass 48 = 0x30
      Wire.endTransmission();
    
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x3f); // DataFlashBlock()
      Wire.write(offset / 32); // 21/32 = 0x00
      Wire.endTransmission();
      
      Wire.beginTransmission(BQ34Z110_ADDRESS);
      Wire.write(0x40); // BlockData()
      Wire.endTransmission();
      Wire.requestFrom(BQ34Z110_ADDRESS, 32, true);
      Wire.readBytes(flash_block_data, 32); // read 32 bytes
    
    
      Serial.println("Read Data Flash New");
      for (int i = 0; i < 32; i++)
      {
        Serial.printf("%02i. 0x%02x\r\n", i, flash_block_data[i]);
      } 

  • Hello Nur,

    The code for each micro can behave differently due to differences in implementation

    . I would recommend that you use bqStudio. Turn off dashboard refresh and then use Advanced comm tab to perform the steps. You can then monitor the bus and compare with your implementation.