2019-02-28 01:48 AM
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.
Solved! Go to Solution.
2019-02-28 03:00 AM
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.
2019-02-28 03:00 AM
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.
2019-02-28 03:10 AM
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.
2019-02-28 05:38 AM
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.