Quantcast
Viewing all articles
Browse latest Browse all 35901

BQ27532 I2C Can someone explain how on earth the commands work please (from a very experienced embedded engineer)

Folks,

I am struggling to understand what on earth the BQ27532 datasheet is on about when it comes to explaining how to interface over I2C. The datasheet is just terrible when it comes to explaining the commands. I cannot even begin to understand what it's on about! I have twenty-five years' experience of writing embedded code and interfacing to I2C, SPI, UART, Ethernet etc etc etc, but have no clue whatsoever as to what TI are going on about with this chip.

So...

...it says you have Command Codes and lists them as things like 0x01 and 0x02 for Control(), 0x0C and 0x0D for Nominal Available capacity etc.

With that in mind, if you want to read back Nominal Available capacity do you send two one-byte write commands to address 0x55, the first with CMD byte as 0x0C and the second as 0x0D? If so, what about the data bytes in those two I2C transactions? And then how do you read it back? It is two quick reads?

What about when writing? If you want to write to the At Rate register? Do you send two one-byte write commands to 0x02 and then 0x03 with the most significant data byte being one write and the low in the other? If so, what comes first? High byte or low byte? If that's not how you do it, what is the method?

Then we come to the utterly unfathomable Control() which is command code 0x00 and 0x01, then  has control data. Does that mean you write single commands of 0x00 and then 0x01 this time with the command data being what is sent as the data byte in the two write commands? So if you wanted to get, say, the device type back would be doing the following?

Write Sequence 1: ADDR CMD DATA 0x55 0x00 0x00

Write Sequence 2: ADDR CMD DATA 0x55 0x01 0x01

Then two quick reads ie: ADDR DATA ADDR DATA 0x55 0xYY 0x55 0xZZ where the device type returned would be made into a 16-bit in 0xYYZZ = 0x0532 in this case? That's assuming, of course, it would send back the MSB first!

I think what would be really helpful is a couple of examples of how to interface with it. I don't need code, it's more something along the lines of:

1. Do 1-byte Write with what ADDR CMD and DATA should be

2. Do another 1-byte write with what ADDR CMD and DATA should be

(I'm fairly use ADDR will always be 0x55)

3. Do a read  in whichever way that read should be done. Two one-bytes, incremental with whatever the CMD should be

etc

Please note I'm using ADDR, CMD and DATA as they appear in section 8.5.4.1 of the SLUSBU6 datasheet and 8.1 of the SLUUB04 technical reference. I realise that the data becomes 0xAA or 0xAB depending on whether it's a read or write. I know I2C. :)

Also, it goes on about instructing the fuel gauge to return things like device type (when doing Control() command and then requesting DEVICE_TYPE)  to addresses 0x00 and 0x01. What are these addresses?! How do I access these addresses?!


If someone could just give me one or two read and write examples in that sort of format I might be able to understand what's going on.


Many thanks. :)


Viewing all articles
Browse latest Browse all 35901

Trending Articles