We know that it's tough to talk to the fuel gauge chip on the Fuel Tank BoosterPack. Its I2C interface is sensitive to right timings.
The Dangerous Prototypes Bus Pirate is famous for its sturdy communication prototyping capabilities. Before I test the Fuel Gauge IC in my own design, I want to test out the communication, and capture some question-reply sequences with a logic analyzer.
In this first post I will try out the communication via I2C, and I'll list some Bus Pirate commands that you can re-use for your own tests.
I'm using a Bus Pirate 4 - but this exercise works equally well with a 3. Just take care that you use the Pirate v3 Reference card for the connections instead of the one for v4 below.
The picture below shows which 3 of the 12 probes we need to use.
And this picture shows where the corresponding signals are on the BoosterPack.
The pull-ups are already available on the board (as long as we keep JP3 in place. We can just connect ground, data and clock.
To test the commands, navigate through the Bus Pirate and enable the hardware I2C mode, 100 kHz. (m - 4 - 2 - 1).
We'll first try an easy command: how much energy left in the battery (in %):
I2C>[0xaa 0x20 [0xab rr ] I2C START BIT WRITE: 0xAA ACK WRITE: 0x20 ACK I2C START BIT WRITE: 0xAB ACK READ: 0x62 READ: ACK 0x00 NACK I2C STOP BIT I2C>
We get back 0x00 / 0x62. That's 98% in the decimal world.
The second command is a bit more elaborate. We'll read the firmware version. That is a control command and requires that we put the IC in control command mode first.
I2C>[0xaa 0x00 0x02 0x00] [ 0xaa 0x00 [0xab rr ] I2C START BIT WRITE: 0xAA ACK WRITE: 0x00 ACK WRITE: 0x02 ACK WRITE: 0x00 ACK I2C STOP BIT I2C START BIT WRITE: 0xAA ACK WRITE: 0x00 ACK I2C START BIT WRITE: 0xAB ACK READ: 0x00 READ: ACK 0x04 NACK I2C STOP BIT I2C>
We get back 0x04 / 0x00 -> Version 4.0
Here's a list of Bus Pirate commands that I forged together and may be of help:
[0xaa 0x08 [0xab rr ]
result / 1000
[0xaa 0x06 [0xab rr ]
result / 10 - 273
[0xaa 0x1e [0xab rr ]
state of charge
[0xaa 0x20 [0xab rr ]
result in %
[0xaa 0x2e [0xab rr ]
result in mAh
Control commands and more elaborate examples
[0xaa 0x00 0x00 0x00] [ 0xaa 0x00 [0xab rr ]
[0xaa 0x00 0x01 0x00] [ 0xaa 0x00 [0xab rr ]
Data Flash Version code
[0xaa 0x00 0x1f 0x00] [ 0xaa 0x00 [0xab rr ]
[0xaa 0x00 0x02 0x00] [ 0xaa 0x00 [0xab rr ]
[0xaa 0x00 0x03 0x00] [ 0xaa 0x00 [0xab rr ]
Read multiple items: v, t , version
[0xaa 0x08 [0xab rr ][0xaa 0x06 [0xab rr ][0xaa 0x00 0x02 0x00] [ 0xaa 0x00 [0xab rr ]
The project has been on the backburner for a while - the video below is more than a year old - but that's how things go sometimes.
In a next installment, I'll capture the traffic with my logic analyzer.
|part 1: Communication Test with a Bus Pirate|
|part 2: Capture Test Communication with a Papilio|
|part 3: First Attempt with Hercules LaunchPad|