This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ76940: I2C(TWI) communication error

Part Number: BQ76940

Hi, I need some help. I'm in trouble with I2C Communication error with my host controller AT90CAN128 chip.

When I'm trying to recieve ACK pulse from BQ76940, I got strange level of pulse.

Here are my codes and it's picture of osc waveform.

BYTE data=0;

TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
while((TWSR & 0xF8)!= 0x08);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWDR = 0x10;

TWCR = (1<<TWINT)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
//while((TWSR & 0xF8)!= 0x18);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Delay(10);
TWDR = reg_addr;

TWCR = (1<<TWINT)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
//while((TWSR & 0xF8) == 0x28);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
//while((TWSR & 0xF8)!= 0x10);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWDR = 0x11;

TWCR = (1<<TWINT)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
PORTA = TWSR;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWCR = (1<<TWINT)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));

PORTA = TWSR;

Delay(10);

data=TWDR;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN);

return data;

->> upper codes makes this waveform

BYTE data=0;

TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
while((TWSR & 0xF8)!= 0x08);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWDR = 0xF0;

TWCR = (1<<TWINT)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
//while((TWSR & 0xF8)!= 0x18);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Delay(10);
TWDR = reg_addr;

TWCR = (1<<TWINT)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
//while((TWSR & 0xF8) == 0x28);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
//while((TWSR & 0xF8)!= 0x10);
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWDR = 0xF1;

TWCR = (1<<TWINT)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));
PORTA = TWSR;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWCR = (1<<TWINT)|(1<<TWEN);

while (!(TWCR & (1<<TWINT)));

PORTA = TWSR;

Delay(10);

data=TWDR;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
TWCR = (1<<TWINT)|(1<<TWSTO)|(1<<TWEN);

return data;

->>this codes have wrong slace address for cheking NACK signal.

BQ76940 sends strange level of ACK pulse(bit:0), but NACK pulse levels are normal.

How can I solve this problem?