We are using da14531 dev kit and trying to communicate with two i2c sensors , azotec trackpad module and mcp23017 gpio expander.We have written drivers for the modules and are able to communicate with the modules independently , however when we are simultaneously trying to communicate with both the modules we are facing an issue. In our code we have declared the i2c config structure as
// Configuration struct for I2C static const i2c_cfg_t i2c_cfg = { .clock_cfg.ss_hcnt = I2C_SS_SCL_HCNT_REG_RESET, .clock_cfg.ss_lcnt = I2C_SS_SCL_LCNT_REG_RESET, .clock_cfg.fs_hcnt = I2C_FS_SCL_HCNT_REG_RESET, .clock_cfg.fs_lcnt = I2C_FS_SCL_LCNT_REG_RESET, .restart_en = I2C_RESTART_ENABLE, .speed = I2C_SPEED_FAST, .mode = I2C_MODE_MASTER, .addr_mode = I2C_ADDRESSING_7B, .address = MCP23017_ADDRESS, .tx_fifo_level = 1, .rx_fifo_level = 1, };
and everytime we are communicating with an i2c device we are setting up the function
i2c_set_target_address(I2cdevice_ADDRESS);
and trying to communicate with the device.
could you kindly point us to some examples about how to communicate simultaneously with multiple i2c devices. we went through the eeprom example but things are not yet clear. many thanks for the help.
Device:
Hi sripathi,
Thanks for your question. So, if I can understand correctly, your requirement is to connect 2 x I2C slaves to same bus. Is my understanding correct?
Thanks, PM_Dialog
Hi,
Yes
你能让我们知道任何工作的吗g example with two i2c slaves . Thanks
Hi sripathi,
Thanks for the clarification. There is not such an example and it is not possible to interact with 2 I2C slave simultaneously and at the same bus. You should interact with only one slave at the same time.
Thanks, PM_Dialog
Hi,
not sure if it still relevant, I solved it by createing an i2c_target_select function, which re-initializes the i2c peripheral with a new set of parameters (eg. different target address). Communication does not happen strictly at the same time but sequentially, as soon as one transfer finished, the other one starts.
The i2c_set_target_address function can unfortunately only be called when the i2c peripheral is diabled and is used by i2c_init to set up the peripheral.
Br, J
Hi jsageder,
Thanks for your comment and the feedback!
Thanks, PM_Dialog