Dear Sir:
I am working on bq27542-g1. I want to change "Design Energy Scale " through I2c interface.
According to MSP430's exsample . I wrote my code. but it can not work.
My code is as follows:
#define bq27541CMD_DFCLS 0x3E
#define bq27541CMD_DFBLK 0x3F
#define bq27541CMD_ADF 0x40
#define bq27541CMD_ACKSDFD 0x54
#define bq27541CMD_DFDCKS 0x60
#define bq27541CMD_DFDCNTL 0x61
#define bq27541CMD_DNAMELEN 0x62
#define bq27541CMD_DNAME 0x63
IIC_Write_One_Byte(bq27541CMD_DFDCNTL, 0);// BlockDataControl() = 0x00
IIC_Write_One_Byte(bq27541CMD_DFCLS, 48); // Write the subclass value
IIC_Write_One_Byte(bq27541CMD_DFBLK, 0);// Select offset within the flash
IIC_Read_Bytes(bq27541CMD_ADF, &TxData[0],32); // Read the contents of the block
TxData[23]=10; //set Design Energy scale=10 for support 20Ah, P90
for (i = 0,sum=0; i < 32; i++) // Compute the checksum of the block
{
sum += TxData[i]; // Calculate the sum of the values
}
checksum = (0xFF - (sum & 0x00FF)); // Compute checksum based on the sum
IIC_Write_One_Byte(bq27541CMD_DFDCKS, checksum); // Write checksum value
for (i = 0; i < 32; i++) // Write 32 bytes to
{
IIC_Write_One_Byte((bq27541CMD_ADF+i), TxData[i]);
}