I'm trying to talk to this MAX17048 battery fuel gauge. I designed a board and soldered it using a hot plate. I fear I may have either not completely soldered it or may have fried the chip during soldering because I can't seem to talk to it. However, this is the first time I've used I2C and maybe I've gotten the software wrong or am having a problem with pullups. I have a 10k pullup on each of SCL and SDA. The datasheet for the chip gives the command sequence to read a register as:
Start | SAddr W | A | MAddr | A | Sr | SAddr R | A | Data0. | A | Data1 | A | ... | DataN | N | Stop
Black is master and red is slave. SAddr W is 0x6C (write) and SAddr R is 0x6D (read). MAddr is the register address. Sr means "repeated start" but I'm not totally sure what that really means.
I'm using nox771's I2C library. The code is:
I've tried all combinations of Wire_PULLUP_EXT/Wire_PULLUP_INT and Wire_RATE_100/Wire_RATE_400 (datasheet says clock <= 400khz).
I don't have an oscilloscope, but I used a Salae logic analyzer to capture this trace:
My read of this that the fuel gauge chip is not acknowledging the transmission from the master by pulling the SDA line low at the ninth transition just before +0.1ms.
Does this seem right?
I've read that there's oddness around the pullups on the teensy 3. Could this be related, or, as is I suspect more likely, my chip dead or not wired correctly?
I understand that an oscilloscope would be preferable because maybe the chip does try to pull SDA low but can't quite get it low enough or something. Any other debugging ideas short of buying an oscilloscope?
Thanks a bunch,
-c
Start | SAddr W | A | MAddr | A | Sr | SAddr R | A | Data0. | A | Data1 | A | ... | DataN | N | Stop
Black is master and red is slave. SAddr W is 0x6C (write) and SAddr R is 0x6D (read). MAddr is the register address. Sr means "repeated start" but I'm not totally sure what that really means.
I'm using nox771's I2C library. The code is:
Code:
Debug.println("hello");
Debug.flush();
digitalWrite(13, 1);
Wire.begin(Wire_MASTER, 0x00, Wire_PINS_18_19, Wire_PULLUP_EXT, Wire_RATE_100);
Wire.beginTransmission(0x6c); // slave addr
Wire.write(0x08); // memory address
Wire.endTransmission(Wire_STOP); // blocking write (NOSTOP triggers RepSTART
Wire.requestFrom(0x6D,2,Wire_NOSTOP); // blocking read on next Wire command)
int16_t val = 0;
bool read = false;
while(Wire.available()) // slave may send less than requested
{
char c = Wire.readByte(); // receive a byte as character
val += val << 8 + c;
read = true;
}
if (read) {
digitalWrite(13, 0);
Debug.print("version: ");
Debug.print(val);
} else {
Debug.print("no response.");
}
Debug.println();
Debug.flush();
I've tried all combinations of Wire_PULLUP_EXT/Wire_PULLUP_INT and Wire_RATE_100/Wire_RATE_400 (datasheet says clock <= 400khz).
I don't have an oscilloscope, but I used a Salae logic analyzer to capture this trace:
My read of this that the fuel gauge chip is not acknowledging the transmission from the master by pulling the SDA line low at the ninth transition just before +0.1ms.
Does this seem right?
I've read that there's oddness around the pullups on the teensy 3. Could this be related, or, as is I suspect more likely, my chip dead or not wired correctly?
I understand that an oscilloscope would be preferable because maybe the chip does try to pull SDA low but can't quite get it low enough or something. Any other debugging ideas short of buying an oscilloscope?
Thanks a bunch,
-c
Last edited: