SLUUCD5 January 2023 BQ27427
The following example shows the command sequence needed to modify a Data Memory parameter. For this example, the default Design Capacity is updated from 1000 mAh to 1200 mAh. All device writes (wr) and reads (rd) refer to the I2C 8-bit addresses 0xAA and 0xAB, respectively.
Step | Description | Pseudo Code | |
---|---|---|---|
1 | If the device has been previously SEALED, UNSEAL it by sending the appropriate keys to Control() (0x00 and 0x01). Write the first 2 bytes of the UNSEAL key using the Control(0x8000) command. Without writing any other bytes to the device, write the second (identical) 2 bytes of the UNSEAL key using the Control(0x8000) command. Note: The remaining steps in this table will use this single-packet method when writing multiple bytes. |
| |
2 | Send SET_CFGUPDATE subcommand, Control(0x0013). |
| |
3 | Confirm CFGUPDATE mode by polling Flags() register until bit 4 is set. May take up to 1 second. |
| |
4 | Write 0x00 using BlockDataControl() command (0x61) to enable block data memory control. |
| |
5 | Write 0x52 using the DataBlockClass() command (0x3E) to access the State subclass (82 decimal, 0x52 hex) containing the Design Capacity parameter. |
| |
6 | Write the block offset location using DataBlock() command (0x3F). Note: To access data located at offset 0 to 31, use offset = 0x00. To access data located at offset 32 to 41, use offset = 0x01. |
| |
7 | Read the 1-byte checksum using the BlockDataChecksum() command (0x60). |
| |
8 | Read both Design Capacity bytes starting at
0x46
(offset = 6). Block data starts at 0x40, so to read the data of a
specific offset, use address 0x40 + mod(offset, 32). Note: LSB byte is coincidentally the same value as the checksum. |
| |
9 | Write both Design Capacity bytes starting at 0x46 (offset = 6). For this example, the new value is 1200 mAh. (0x04B0 hex) |
| |
10 | Compute the new block checksum. The checksum is (255 – x) where x is the 8-bit summation of the BlockData() (0x40 to 0x5F) on a byte-by-byte basis. A quick way to calculate the new checksum uses a data replacement method with the old and new data summation bytes. Refer to the code for the indicated method. |
| |
11 | Write new checksum. The data is actually transferred to the Data Memory when the correct checksum for the whole block (0x40 to 0x5F) is written to BlockDataChecksum() (0x60). For this example New_Csum is 0x1F. |
| |
12 | Exit CFGUPDATE mode by sending SOFT_RESET subcommand, Control(0x0042). |
| |
13 | Confirm CFGUPDATE has been exited by polling Flags() register until bit 4 is cleared. May take up to 1 second. |
| |
14 | If the device was previously SEALED, return to SEALED mode by sending the Control(0x0020) subcommand. |
|