2015-01-27 11:18 PM
Hi Guys,
I used the STM32L152 mcu, and used the CubeMX tool to generate sample code and HAL code.I have two I2C devices, one is OLED, one is EEPROM (AT24C512).The question is the OLED is one address, but the EEPROM has dual address.I need use the one I2C to drive the OLED and EEPROM.How to set the I2C register? hi2c2.Instance = I2C2; hi2c2.Init.ClockSpeed = 100000; hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2; hi2c2.Init.OwnAddress1 = 0; hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
hi2c2.Init.OwnAddress2 = 0; hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED; hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; HAL_I2C_Init(&hi2c2); Maybe I need change the register dynamic?Is it possible to work? By the way, How to set the value of OwnAddress1 and OwnAddress2? Thank you.Kevin #stm32 #i2c #eeprom2015-01-28 08:17 PM
Has some person can give me a hand?
Thanks a lot.2015-01-29 03:51 AM
Your MCU is likely to be the I2C master, there is no need to care about ''own address'' nro ''dual address mode'', because those are I2C slave features.
You only are required to init your I2C controller as master, then perform read and writes to sensors wrt. their functional descriptions.