Hi All,
Because the code posted by cheerio has been - by far - the most helpful tool to understand comms with the BQ34z110, I'd like to revive this thread.
I have very little reference data to figure out whether I'm going in the right direction. I'm using comparisons to default values for CHEM_ID (0x800), DEVICE_TYPE (0x110) gleaned from other's posts in TI's E2E forum, and Temperature() from the external NTC (actual temperature in my room) to figure out how to communicate and decode.
Also, I'm using a PIC18, BusPirate, and arduino for I2C comms (i.e. not TI's EVS boards), and a logic analyzer to observe byte and bit orders and decode bytes sent and received.
The fog is slowly lifting, but I'd be grateful if someone could confirm my conclusions (or suspicions?) thus far:
1) For Control commands, the order in cheerio's code seems to be AA+CNTL_LO_BYTE+CNTL_HI_BYTE, followed by AA+0x01+0x01, then AA+0x00 (set the pointer to the LO register?), then AB (read). The BQ responds with LO_BYTE then HI_BYTE. For CHEM_ID (0x0008), this means AA+00+08, AA+01+00, AA+00, AB, response 0x00 (LO) then 0x08 (HI). Left-shifting the HI byte (0x08) by 8 bits and adding the LO byte (0x00) gives a 16-bit word 0000100 00000000 with a value matching the default CHEM_ID of of 0x800.
While this matches the expected default value (and also works for CHEM_ID), we're sending sub-command first, then Control(). This is inverse to the order described in the datasheet (p9): "Issuing a Control() command requires a subsequent two-byte sub-command". The data sheet doesn't seem to erroneous (the order Control() then sub-command (0x00+0x01 then 0x00+0x08 also returns 0x800!). Please note that I'm not complaining about the code (I love it!), I'm simply confused: why do both ways work? I'm also concerned that I may be badly mis-understanding things ...
2) cheerio's code to retrieve TEMP (a simple and ingenious tx1(0x0d0c);
) produces a word (0xD0C), but only 0xAA+ACK, 0x0C+ACK, and 0xAB+ACK are sent over I2C. The HI byte of the word never appears on the pins. Surprisingly, the BQ responds with the expected temperature value! (LO byte first). Is this because the arduino's wire library (and the other 8-bit MCU's I"m using) can't cope with a 16-bit word and send only the LO byte? And how is this understood correctly by the BQ34z110?
3) Is the order of bytes returned consistently LO byte first, as for Temperature()?
4) Are the bytes coming from the BQ34 consistently MSBit first, as in the (testable) cases CHEM_ID, DEVICE_TYPE, and Temperature?
Sorry for these basic questions, it's hard to figure out reliably with limited reference data.
Many thanks in advance for all replies!
K