Skip to main content
neovius
Associate
February 28, 2019
Solved

Bug STMF1x CubeMX I2C Slave Address

  • February 28, 2019
  • 3 replies
  • 1226 views

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.

This topic has been closed for replies.
Best answer by Andreas Bolsch

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.

3 replies

Andreas Bolsch
Andreas BolschBest answer
Lead III
February 28, 2019

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
neoviusAuthor
Associate
February 28, 2019

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
February 28, 2019

​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