1
\$\begingroup\$

I'm trying to learn how to program a battery charging IC (BQ24193) via the I2C communication protocol. My goal is to write the correct values to it in order to gain the proper charging input and output current (I will be using an arduino to program this if that matters).

When going through the datasheet, what I don't understand is the actual address of the slave and the address of the register. Talking to a Texas Instrument engineer, he said that the address given in the datasheet is the address for the register 6BH (which I am assuming is just 0x6B). He also said the the slave address is sent after the start condition. So I have no idea what that means since I always thought the slave address value was given in the datasheet.

Datasheet: http://www.ti.com/lit/ds/symlink/bq24193.pdf

So the questions I have: How on earth do I, the programmer, get the slave address in order to write to the IC? How do I write to a specific register if all of the registers have the value 6BH?

Any help would be appreciated. Thanks.

\$\endgroup\$
  • 1
    \$\begingroup\$ Arduino has easy to use library functions for I2C. There is a device address associated with all I2C slaves; this is the address to pass to the library function. 6B (hex) is the device address. \$\endgroup\$ – Peter Smith Sep 6 at 15:35
5
\$\begingroup\$

The start condition is what tells the other devices to start listening. Same thing with regular RS232. Here is an image from a sparkfun.com article about I2C. As you can see the start condition is the state change of the clock and data in the beginning. The real trick is to get the device address correct. It is a 7 bit address left justified in the first 8 bits and bit 0 is the read/write bit. So if the datasheet says 0x6b, then on the wires it'll look like 0xd6 or 0xd7 depending on the state of the read/write bit.

enter image description here

As for the data, it's the next 8+ bits. Everything is normal there. So you will always send at least 16 bits every time when writing, probably more because you'll probably have to specify the register within the device. When reading, the device will take over the SDA line, after the address is sent, and send data as you clock it.

\$\endgroup\$
4
\$\begingroup\$

According to the datasheet the slave address is: 0x6B.

The available registers you can access are REG00 - REG0A. Therefore the address of each register would be:

REG00 = 0x00
REG01 = 0x01
REG02 = 0x02
REG03 = 0x03
REG04 = 0x04
REG05 = 0x05
REG06 = 0x06
REG07 = 0x07
REG08 = 0x08
REG09 = 0x09
REG0A = 0x0A

For example if you want to write the value 0x31 in the register Input Source Control Register REG00 enter image description here

\$\endgroup\$
2
\$\begingroup\$

Looking at the datasheet, I don't see it spelled out explicitly, but I would assume that the register addresses are based on the name of the register.

For example, REG05 is at address 0x05 and REG0A is at address 0x0A.

All communication with the part will use I2C slave address 0x6B given before the register address.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.