Hi,
I'm trying to configure the bq27510 Gas Gauge without using the user interface, since I don't expose the SDA/SCL pins.
I've read the datasheet and various threads on this forum, but I still have problems with the write process.
As an example, I try to change the Op Config register from 0x0979 to 0x0978. My I2C routines use as parameters: the component 7-bit address, an address/data buffer, the number of bytes to write/read
// Write BlockDataControl
off[0] = 0x61; off[1] = 0x00;
I2CWrite(0x55, off, 2); WaitDelay();
// Write DataFlashClass
off[0] = 0x3E; off[1] = 0x40;
I2CWrite(0x55, off, 2); WaitDelay();
// Write DataFlashBlock
off[0] = 0x3F; off[1] = 0x00;
I2CWrite(0x55, off, 2); WaitDelay();
// Calculate checksum
off[0] = 0x60;
I2CWrite(0x55, off, 1);
I2CRead(0x55, &checksum, 1);
checksum -= 0xFF;
checksum = 0x79 - checksum; // convert old value...
checksum += 0x78; // ...with new value
checksum = 0xFF - checksum;
// Write new data
off[0] = 0x41; off[1] = 0x78;
I2CWrite(0x55, off, 2); WaitDelay();
// Write checksum
off[0] = 0x60; off[1] = checksum;
I2CWrite(0x55, off, 2); WaitDelay();
That's all.
....and it doesn't work! The value will never be updated.
Am I missing something?
Also, reading the control status like this
// Calculate checksum
off[0] = 0x00; off[1] = 0x00; off[2] = 0x00;
I2CWrite(0x55, off, 3);
I2CRead(0x55, status, 2);
I get a status 0x0400 or 0x0004 (I don't remember the correct one. By the way, both values state that the device is not in sealed mode)