cancel
Showing results for 
Search instead for 
Did you mean: 

Bug STMF1x CubeMX I2C Slave Address

neovius
Associate

When setting the primary slave address for I2C in cubeMX for the STM32F1xx

The generated code will be the address * 2.

This created address is incorrect. The address should not be multiplied by 2.

for example:

Set I2c Slave address to 0x50

Generated code sets the OwnAddress to : 160. which is (0x50 * 2)

The st does not response to the address 0x50, because the ownAddress is set to another value.

1 ACCEPTED SOLUTION

Accepted Solutions
Andreas Bolsch
Lead II

No, that's not a bug. The I2C address (7-bit) is transmitted left justified in the corresponding byte, bit 0 is the R/W bit. The description of I2C_OAR1 shows clearly that the address is left justified there, too.

View solution in original post

3 REPLIES 3
Andreas Bolsch
Lead II

No, that's not a bug. The I2C address (7-bit) is transmitted left justified in the corresponding byte, bit 0 is the R/W bit. The description of I2C_OAR1 shows clearly that the address is left justified there, too.

neovius
Associate

Ah I didn`t read the description of the "Primary slave address" input field. I though that the address that i put in the field, is the write address of the ST.

But apparently the address i put i the field is the non shifted address.

Khouloud ZEMMELI
ST Employee

​Hello @neovius​ 

The generated value of the adress is shifted left by 1 bit( as it's indicated in the screenshot) , that's why you find 160 instead of 80 in your code.

(thank you @Andreas Bolsch​  for the quick answer.)

Regards,

Khouloud.

0690X000006Dun4QAC.png