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.

BQ27510 - write data flash

Other Parts Discussed in Thread: BQ27510, BQ27510-G1, BQEVSW

hello,

I'm developping a driver in C language to control a fuel guage BQ27510.

I have no problem to read the standard/sub/extend command and to write the standard command. but I can't write data on "data flash" with the extend command.

the function is this one :

    if(!(FuelGauge_WriteExtendedCmd(BQ27510_EXTCMD_BLOCKDATACONTROL, &dataCtrl, 1)))
      return false;
    if(!(FuelGauge_WriteExtendedCmd(BQ27510_EXTCMD_DATAFLASHCLASS, &classId, 1)))
      return false;
   
    if(!(FuelGauge_WriteExtendedCmd(BQ27510_EXTCMD_DATAFLASHBLOCK, &Block, 1)))
      return false;
   
    ValCheckSum = FuelGauge_CalcChecksum (DataBlock, sizeWrite);
    if(!(FuelGauge_WriteExtendedCmd(BQ27510_EXTCMD_BLOCKDATA, DataBlock, sizeWrite)))
      return false;

    if(!(FuelGauge_WriteExtendedCmd(BQ27510_EXTCMD_BLOCKDATACHECKSUM, &ValCheckSum, 1)))
      return false; 

with : dataCtrl = 0x00, Block = 0x00, classId = 58, sizeWrite = 32 and DataBlock is my data on 32 bytes. the IC is in full access mode.

I try to write on the manufacturer Info block A but it doesn't work.

Could someone help me to find the mistake ?

thanks

  • OK, the most common tripups are:

    Make sure you write your checksum properly: note that the checksum byte needs to be complemented.  Also, the checksum contains only the information written to BlockData().  It does not include the Class or Block designation. 

    If it isn't one of these, could you post your exact I2C command sequence? 

    Thanks,

    Charles

  • Thanks for your answer.

    Of course, the cheksum contains only the BlockData() information. I'm sure that the checksum is correct and I write it properly.

    I think that my I2C command are good because the data flash read function, standard command read and write functions work. The I2C adress is 0xAA.

     

    In the application note slua541 (about updating firmawre at production) they explain that it's necessary to use the 'ROM mode' to update the firmware and the golden pack. Is it necessary to be in this mode to write any data in data flash rom ?

     

  • You don't need to be in ROM mode to perform the data flash manipulation you are talking about. 

    Your high level code sequence seems OK from what I can see, so I think that this might be an issue with the I2C handling.

    The timing requirements change when you are writing the flash over I2C.  (See page 31-32 of the bq27510 data sheet). 

    A flash write takes a significant amount of time, during which the gauge streches the clock up to 80ms.  It also requires a 20ms delay before you can read this data again.  In addition, we recommend a 66uS delay between I2C commands. 

    Let me know if this helps,

    Charles

  • thanks, I didn't have this timing informations in the bq27510 datasheet. I find them in the bq27510-g1 datasheet.

    I will include the 66µs delay but I don't understand where is the 80ms delay after writing the flash. In my function, I write the flash with a 32 bytes incremental write ; then I have to wait 80ms after writing this 32 bytes or in another moment ?

    For my development, I used the example for MPS430 processor but there is no information about this delay on I2C.

    Do you have a good example which explain how to write in data flash ?

     

  • The 80mS delay occurs immediately after you write the checksum.  Writing the block data stores the data in I2C registers.  When you write the checksum, the firmware verifies the data and then writes the flash. This is where your delay needs to be.

    We are actually currently in the process of updating that application note with this information.  I'll see if I can grab the code update and post it here.

    Thanks,

    Charles

  • To debug my software I execute it step by step ; then, I respect the 80ms delay.

    Is there a way to check if the checksum writen and the data verification succeded ?

    Thanks.

  • I am having a similar issue writing the Manufacturer Info Blocks on the BQ27510-G1.

    Why is it that in the datasheet the Subclass ID is 58 (0x3A), but when I spy on the EVM, transactions that use the Data Flash->System Data screen result in Subclass ID 57 (0x39) being requested over I2C ?  I am using EV2300 with bqEVSW 0.9.59 and V1.12 SENC.

    Thanks

     

     

  • That is an error in the datasheet.  We actually found this just recently and will have it corrected as soon as possible in the next revision of this datasheet.

    The subclass ID for the Manufacturing information on the bq27510 G1 is 57 and NOT 58. 

    After finding this error, I went through the remainder of the data flash summary and verified that it matched the actual flash image.  This was the only error that I could find.

    Excellent catch, and we will get this corrected as soon as we can.

     

    Thanks,
    Charles

     

  • surfnsand, charles, thanks for this important information. I change the subclass to 57 and it looks to work.

    Now, I need to test the other subclass. And if I understand well, to write a subclass we have to write a 32 bytes block instead of the size of the subclass is smaller (for exemple Registers subclass). Is it true ?

     

  • Yes, a subclass is broken down into blocks, each of which contains 32 bytes. Each byte of information exists at a certain offset from a subclass.  For example, an item at offset 0 would be at block 0 at index 0.  An item at offset 48 would be in block 1 at index 12.  (no hexadecimal)

    Once you define your subclass ID and Block number, the I2C registers 0x40-0x5F represent the indicated 32 byte block.  Reading these values will return the data in the flash.  Writing to these values and subsequently to the checksum register will write these dataflash values.  Note that you can write individual bytes at a time and the checksum is calculated only from the bytes that you have written.

    Let me know if you have any questions,

    Charles