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.

Problem writing the data flash block in a bq27501

Other Parts Discussed in Thread: BQ27501

I've been having some difficulty writing the contents of the Blockdata() area to flash. I'm using the sequence below with:

fOk = BatteryPDDWriteChar(GAUGE_EXTCMD_DFDCNTL, 0);

fOk = BatteryPDDWriteChar(GAUGE_EXTCMD_DFCLS, subclass);

fOk = BatteryPDDWriteChar(GAUGE_EXTCMD_DFBLK, block);

fOk = BatteryPDDWriteBuf(GAUGE_EXTCMD_DFD, buf, numbytes);

checksum = BatteryPDDChecksum(buf, numbytes);

fOk = BatteryPDDWriteChar(GAUGE_EXTCMD_DFDCKS, checksum);

 

I have no problem reading any of the data flash subclasses, I'm just unable to write them. I thought at first it was an error in the checksum, but I think if an incorrect checksum is written, there is no NACK from the bq27501 and I'm getting one. The checksum calculation seems to be correct because I can read any flash area and verify the calculation versus that read from the bq27501. I'm always writing the whole 32 byte block in the above sequence.

Any help would be appreciated.

Orval

  • hi Orval,

    I don't see any issue with the command sequence. Can you provide more details? An example code will be helpful. I suspect that either the checksum may not be correct.

     

    Ming

  • Ming,

    Below is the checksum calculation. My first thought was that it was a checksum error so I included a loop to try every possible checksum. I received no NACK from the bq27501 unless the checksum was correct.

     

    UCHAR BatteryPDDChecksum(PUCHAR buf, UINT16 numbytes)

    {

      UINT16 sum=0;

      INT16 i;

     

     

      for ( i=0; i<numbytes; i++){

        sum += *buf++;

      }

      sum = 0xff - (sum & 0x00ff);

     

     

      return (UCHAR)sum;

    }

    My code is included in a battery driver for CE 6.0. I2C is a transaction based driver so the previous message was actual code from my driver. They are calls to subroutines that set up the I2C transactions then execute them. All the I2C communication works fine, The 32 byte blocks are actually written to the command space and can be verified, the only problem is that they are never committed back to flash. If I read blocks, run the routine above to create a checksum and verify it against the checksum generated by the bq27501, they are the same as well.

    Any insight would be greatly appreciated.

    Orval

  • Orval,

     

    Here is an example how it should work, Please let me know if this helps>

     

    I want to chnage Temp Hys in Charge inhibit Cfg from 5.0C to 5.5C (from 0x32 to 0x37, unit 0.1C). The subclass is 32 in DEC so it is 0x20 in Hex.And it is on page one so the page offset is 0.

    Write 0x20 into address 0x3e

    write 0x00 into address 0x3f ( to locate the block data)

    read 32 byte from 0x40 which is: 000001c20032000000...

    write into 0x40: 000001c20037000000....

    calculate the checksum: 0x00+0x00+0x01+0xC2+0x37 = 0xFA, take the complementary of least significant byte 0xFF - 0xFA = 0x05 This is the checksum

    write 0x05 into 0x60.

     

    Now read data flash and the Hys is changed from 5.0 to 5.5 (50 to 55)

  • Ming,

    Performed the above with same result, checksum calculates properly, control registers contain proper data, the data just is not written to the flash. I beginning to suspect a problem with my hardware. This is a core board we are going to use in our test instruments, I have another one here that I need to make some mods on, but once I do, I will try it on that hardware to see if it works.

    Orval

  • Ming,

    I think I found the problem, just need to do a test to verify. I read through the whole data sheet and found that the flash can only be updated if the Voltage() >= Flash Update OK Voltage. I then read the Configuration Power Subclass and verified that the update voltage default value was correct and then read the cell voltage. The cell voltage was reading 0. I will just disconnect the cell and supply a voltage to verify that the flash can be updated.

    Thanks for your help, I'll post when I've confirmed this.

    Orval

  • Ming,

    I've confirmed that the problem was the cell voltage. I supplied 3 volts to the battery terminals and was able to write the data flash.

    Thanks again for your help.

    Orval

  • good to know