Other Parts Discussed in Thread: EV2400, BQSTUDIO
Good afternoon,
I am using BQ27421-G1A battery gauge in our project. It was a time to do some power consumption tests and I realised using the battery gauge data will be the easiest way to do so due to equipment limitations.
Hence, I have started tailoring battery gauge to the needs we are having. I have determined all 4 necessary parameters to adjust - Design Capacity(120mAh), Design Energy(444mWh), Terminate Voltage(3200mV) and Taper Rate (500). I have got these number from battery datasheet and applied formulas provided from TI in "Quickstart Guide for bq27421-G1" (page 3-4)
Battery gauge currently in use comes UNSEALED (0x00 register bit 5 is unset), so all data updates can be done straight away.
So, I successfully managed to access registers to read Design Capacity (registers 0x4A, 0x4B), Design Energy (registers 0x4C, 0x4D), Terminate Voltage (registers 0x50, 0x51) and Taper Rate (registers 0x5B, 0x5C) which were set to default values. Hence, registers are written with values determined above. After writing new values, values are read again to confirm that battery gauge received the right values.
Now, to finalise writing procedure and make gauge save new data in NVM storage, a correct checksum has to be calculated and issued. So, I calculate checksum as per method described in "Technical Reference" for a battery gauge (page 16)
To get a step by step disassembled view of all the values received, please refer to attached TXT file.
OLD_Csum = 0xAC OLD_DesCap_MSB = 0x5 OLD_DesCap_LSB = 0x3C OLD_DesEn_MSB = 0x13 OLD_DesEn_LSB = 0x60 OLD_TerVol_MSB = 0xC OLD_TerVol_LSB = 0x80 OLD_TapRat_MSB = 0x00 OLD_TapRat_LSB = 0x64 NEW_DesCap_MSB = 0x00 NEW_DesCap_LSB = 0x78 NEW_DesEn_MSB = 0x1 NEW_DesEn_LSB = 0xBC NEW_TerVol_MSB = 0xC NEW_TerVol_LSB = 0x80 NEW_TapRat_MSB = 0x1 NEW_TapRat_LSB = 0xF4 temp = mod(0xFF - 0xAC - 0x5 - 0x3C - 0x13 - 0x60 - 0xC - 0x80 - 0x00 - 0x64, 0x100) = mod(0x-151, 0x100) = 0xAF NEW_Csum = 0xFF - mod(0xAF + 0x78 + 0x1 + 0xBC + 0xC + 0x80 + 0x1 + 0xF4, 0x100) = 0xFF - mod(0x365, 0x100) = 0xFF - 0x65 = 0x9A
Values calculated by hand and using software match. However, when I am trying to write values to a register, it doesnt accept it - I2C issues the value but battery gauge doesnt respond to received value. Moreover, if I am going to issue SOFTRESET command (0x0042) it seems like it is not coming back to normal mode from CFGUPDATEMODE (Flag for the mode is still set).
So, I am stuck here, not being able to write new calculated checksum even though it looks like a good checksum, calculated as per datasheets. Am I missing some kind of delay after issuing I2C command? I am not using any delay routines when issuing writing commands over I2C to write Design Capacity, Design Energy etc. since when i read them back over I2C bus, they already coming back to me updated. However, is it the case with chechksum? Or there should be some kind of a delay routine to allow gauge to recalculate checksum in the background so it has something to compare with when I actually write checksum over I2C?