Other Parts Discussed in Thread: BQ27510
Dear All,
We have use the I2C for the fuel Guage IC of TI part no. BQ27510DRTZ,
Since the problem not occurred during the stellaris ware Controller but after the same code is being transformed to the TIVA C series Controller the same code is not being working properly,
After so much of my inspection, we came across the conclusion the I2C bus is not being working properly especially when the Write transfer is being done after the Read command.
Our code of action is as follows.
unsigned int BM_Checksum()
{
unsigned int Checksum = 0, i;
while(ROM_I2CMasterBusy(I2C2_BASE));
ROM_I2CMasterSlaveAddrSet(I2C2_BASE, BATTERY_FUELGUAGE_ADDRESS, false);
ROM_I2CMasterDataPut(I2C2_BASE,0x40);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_SEND_START);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
while(ROM_I2CMasterBusy(I2C2_BASE));
ROM_I2CMasterSlaveAddrSet(I2C2_BASE, BATTERY_FUELGUAGE_ADDRESS, true);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
delay_mSec(1);
for(i = 0; i< 32; i++)
{
check_sum_m[i] = ROM_I2CMasterDataGet(I2C2_BASE);
Checksum += check_sum_m[i];
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
while(ROM_I2CMasterBusy(I2C2_BASE));
}
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
while(ROM_I2CMasterBusy(I2C2_BASE));
Checksum = Checksum & 0xFF;
Checksum = 0xFF - Checksum;
delay_mSec(1);
return (unsigned int)Checksum;
}
So after find the Checksum of the fuel guage the Checksum is being calculated correctly by above sample of code but after that when we want to write the
Checksum to the address of fuel guage 0x60 in order to put it on the fuel guage IC.
Here is the code of action for the write of the checksum to the IC at address 0x60.
void BM_Write_Byte(unsigned char Command, unsigned char data)
{
while(ROM_I2CMasterBusy(I2C2_BASE));
ROM_I2CMasterSlaveAddrSet(I2C2_BASE, BATTERY_FUELGUAGE_ADDRESS, false);
ROM_I2CMasterDataPut(I2C2_BASE, Command);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(ROM_I2CMasterBusy(I2C2_BASE));
ROM_I2CMasterDataPut(I2C2_BASE, data);
ROM_I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
while(ROM_I2CMasterBusy(I2C2_BASE));
}
Is this code of sample is correct???