Quantcast
Viewing all articles
Browse latest Browse all 35901

BQ27200 - I2C Incremental Read - Only first byte is sent

I am working on a prototype of a rechargeable battery pack for a commercially produced Arduino shield and I am trying to test the communications with the BQ27200 Gas Gauge IC that we have included in the design. I have tried using the "Wire" library (offically supported by Arduino) and an alternative I2C library with better implementation of the repeated start condition.

My test program is as follows:

#include <Wire.h>

byte data[6];

unsigned int Temperature;
byte Add;

void setup()
{
Serial.begin(9600);
Wire.begin();
}

void loop()
{ 
Serial.println("Beginning I2C Test");
Serial.println("Reading Temperature...");
Wire.beginTransmission(0x55);
Wire.write(byte(0x06));
Wire.endTransmission();
Wire.requestFrom(0x55,6);
int i = 0;
while (Wire.available())
{
data[i++] = Wire.read();
}
Wire.endTransmission();
while (i>0)
{
Serial.println(data[--i],BIN);
}
Serial.print("\n\n");
delay(2700);
}

The output is (Memory address top byte 0x0B, bottom: 0x06): 


Beginning I2C Test
Reading Temperature...
11111111
11111111
11111111
11111111
11111111
11010111

It is a little confusing looking at this because it is listed in reverse, but it is printed in the format of the memory map in the datasheet. These values are read in order from the bottom (B11010111) to the top. The first byte read is correct, but the rest are obviously not. My interpretation is that the bq27200 seems to be stopping the transmission after the first byte is sent. Perhaps it is interpreting a STOP instead of an ACK? Below is a capture of this moment in the communications (the end of the first byte read).  Both libraries resulted in the exact same waveform. Any help would be appreciated.

Thanks, Aaron

Image may be NSFW.
Clik here to view.


Viewing all articles
Browse latest Browse all 35901

Trending Articles