AnsweredAssumed Answered

STM32 Cube HAL I2C DualAddressMode and Not DualAddressMode

Question asked by liao.chengyi on Jan 28, 2015
Latest reply on Jan 29, 2015 by gonzalez.laurent
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

Outcomes