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.

bqp27500: software example to read write in data flash

Other Parts Discussed in Thread: BQ27500

Hello,

where can i find bqp27500 software examples (in c)  to read and write in data flash of the bqp27500 in any block (not only the manufacturer block) ?

Do we need to unseal the data flash before reading or writing any block ?

How can we have access to Full-Access Key  if we can't read the data  flash ?

Thank you

  • Trichet,

     

    Please refer to the "MSP430 Microcontroller Software for Handheld Fuel Gauge & Battery Authentication" (SLVA413A) document in the Technical Documents Section under the Application Notes (http://focus.ti.com/docs/prod/folders/print/bq27500.html#technicaldocuments).  There is a .zip file that will come with this that includes example code (http://focus.ti.com/analog/docs/litabsmultiplefilelist.tsp?literatureNumber=slva413a&docCategoryId=1&familyId=412).

    Another document also in the Application Notes section "Using I2C Communication with the bq275xx Series Fuel Gauges" (SLUA467) is a document that provides information concerning the way to implement I2C commands with the gauge.

    Please refer to the device DS Section 4.2 Data Flash Interface (p. 16) for information concerning how to access the DF, sealed/unsealed access information and access modes.

  • Thank you for your reply,

    i had already downloaded the software example you mentionned, but i still wonder how to modify data flash parameter. It seems that the example provided only show how to write in manufacturer part A,B or C.

    How to proceed to modify other part of the data flash ?

    For exemple i want to change Terminate Voltage in the Fuel Gauging class at offset 48, i do the following :

    1)set mode unseal full access:

    send control command 0x 0414
    send control command  0x3672
    send control command  0xffff
    send control command  0xffff


    2) access the data flash
    send  BlockDataControl() with 0x00
    send DataFlashClass( ) with 0x40 + 48 modulo 32 ( Write the subclass value)

    Then what shall i do to read the block, modify the value and write the block again ?

       
    3)now set sealed mode :

    send control command 0x0020

     

    Can you detail to me how to proceed in step 2) ? Thank you

    Best regards

  • Here's how you can read the dataflash using the Block Data commands:

    1. Unseal the device by using Control() if the device is SEALED.
        a. Write the 2-byte data 0x0414 using Control() (0x00) command. (wr 0x00 0x14 0x04)
        b. Write the 2-byte data 0x3672 using Control() (0x00) command. (wr 0x00 0x72 0x36)
    2. Write 0x00 using BlockDataControl() command (0x61) to enable block data flash control. (wr 0x61 0x00)
    3. Write 0xSubclassId using DataFlashClass() command (0x3E) to access subclass. (wr 0x3E 0xSubclassID)
    4. Write block offset location using DataFlashBlock() command (0x3F). To access data located at offset 0 to 31 use offset = 0x00; To access data located at offset 32 to 41 use offset = 0x01. If subclass is more than 32 bytes in size then multiple reads are necessary from incremental offsets. (wr 0x3D 0x00, wr 0x3F 0x1F, …)
    5. To read the data from address 0x40 to 0x5F, where byte0 will be at register 0x40 and byte31 will be at register 0x5F. It can be done by reading subclass_size(max of 32) bytes from register 0x40. (rd 0x40 byte1…byte31).
    6. Re-SEAL the gauge if needed by using Control() 0x0020.

    Example - Data flash read from subclass 82 – State(Gas Gauging). Subclass 82 is 28 bytes.
    1. Unseal the gauge
        a. wr 0x00 0x14 0x04
        b. wr 0x00 0x72 0x36
    2. Enable block data flash control
        a. wr 0x61 0x00
    3. Set SubclassId to 82(0x52)
        a. wr 0x3E 0x52
    4. Set Subclass offset to 0 – we will read from the beginning of subclass
        a. wr 0x3F 0x00
    5. Read 28(0x1C) bytes of data
        a. rd_block 0x40 0x1C
    6. Reseal the gauge. Write 2 bytes 0x0020 to Control command 0x00
        a. wr 0x00 0x20 0x00

    Now, to update one of the dataflash locations: just read the block, read the checksum, then update the block with the modified value, then calculate the new checksum and when you write the new checksum to 0x60 it will transfer the updated values back to dataflash.  Here's a quick way to calculate the new checksum:

    A = (OldChecksum) + (oldDF – newDF)

    NewChecksum = A mod 256