cancel
Showing results for 
Search instead for 
Did you mean: 

I2C HAL own address format?

Mike Hooper
Senior

I have been struggling to get a simple I2C communication link working so that I can talk to my battery charger device. It's device address is 0x68. I have tried shifting this one bit the the left, not shifting the address. Nether works. Can someone shed some light on this statement in the HAL UM1905 User Manual?

DevAddress: Target device address: The device 7 bits
address value in datasheet must be shift at right before call
interface

3 REPLIES 3

Cube/HAL is open source. You may be better off finding where is it stored to the actual register.

JW

TDK
Guru

> * @param DevAddress Target device address The device 7 bits address value

> * in datasheet must be shifted to the left before calling the interface

It expects the slave address to be in the upper 7 bits, so shift it one bit to the right when you call HAL_I2C_* functions.

The HAL is documented pretty well without the source code. Perhaps look there first.

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

For the ST I2C driver, I2C addresses are 7 bit, but shifted 1 bit left.

Then you set bit 0 to 1 for write and 0 for read,

In your hardware documentation, the address may be specified as 7 bit without shift.

This form is common in Linux, for example.

So 0x68 may mean either 0x68/0x69, or 0xD0/0xD1. Try both variants.

ST library has a convenient function HAL_I2C_IsDeviceReady , it can be used to probe the addresses. Most decent devices should reply.

-- pa