Question
STM32 Cube HAL I2C DualAddressMode and Not DualAddressMode
Posted on January 28, 2015 at 08:18
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 #eeprom