Hi there. I designed a PCB based on TI reference for BQ76940. The Altium designer project is attached.
As you can see, I'm trying to host the chip with an stm32f103 microcontroller. Since I didn't find any libraries compatible with my MCU and IDE (Keil V5) I tried to rewrite the Arduino library by SparkFun. I successfully managed to connect to the chip via I2C and read the SYS_STAT register. Another thing that you should know is that I wasn't so sure of my design so I didn't want to test the board with a real LFP battery pack since they are expensive and dangerous! So I used 15 75 ohm resistors in series connected to a 27V power supply and I am planning to change the OV and UV threshold to match my "Battery simulator" and then test the board and the program. The problem I have is with the DEVICE_XREADY situation! No matter what I do, I get 0x20 as soon as the chip is booted and I can't reset the bit. The datasheet indicates that DEVICE_XREADY happens due to excessive transients in the circuit which I don't see anything to cause that So I only can think of three things:
1. The code is not properly written to write a register (I used the HAL library standard functions and I had to use the address 0x30 instead of 0x18 to connect to the chip, I attached the code too) here is what I do:
while(1)
{
RegisterAddress[0] = bq796x0_SYS_STAT;
recievedPack[0] = 0xDF; //Some random number in this format xx0x-xxxx
HAL_I2C_Master_Transmit(&hi2c2, bqI2CAddress, RegisterAddress, sizeof(RegisterAddress), MAX_I2C_TIME); //bqI2CAddress = 0x030 (="0x18")
HAL_I2C_Master_Receive(&hi2c2, bqI2CAddress, recievedPack, 1, MAX_I2C_TIME); //MAX_I2C_TIME = 10
HAL_UART_Transmit(&huart2, recievedPack, 1, 10); //Here I receive 0x20 when I boot the chip with the boot switch
if(recievedPack[0] & bq796x0_DEVICE_XREADY) //bq796x0_DEVICE_XREADY = 1 << 5
{
HAL_Delay(1000); //Wait for a sec then try to rewrite the SYS_STAT register
recievedPack[0] &= ~(bq796x0_DEVICE_XREADY); //Write 0 in the DEVICE_XREADY bit : xx0x-xxxx
HAL_I2C_Master_Transmit(&hi2c2, bqI2CAddress, RegisterAddress, 1, MAX_I2C_TIME);
HAL_I2C_Master_Transmit(&hi2c2, bqI2CAddress, recievedPack, 1, MAX_I2C_TIME);
//here I tried to use the "write without the repeated start" mode but I got nowhere
//recievedPack[1] |= bq796x0_DEVICE_XREADY;
// recievedPack[1] &= ~(bq796x0_DEVICE_XREADY);
// recievedPack[0] = bq796x0_SYS_STAT;
// HAL_I2C_Master_Transmit(&hi2c2, bqI2CAddress, recievedPack, sizeof(recievedPack), MAX_I2C_TIME);
}
HAL_Delay(200);
}
2. The resistors in series don't simulate the battery pack good enough.
3. The chip is damaged and I should change it with a new chip. (Actually, this might be possible since the LDO voltage is 3.8! Is there any way I can be sure of it?)
Any hint on what to do or how to find the source of the error is appreciated.
Thank you,
Best regards,
Arash.BQ76940.rar