ADuCM3029 Multiple I2C Slaves

I'm attempting to communicate with two slaves on I2C, using the ADuCM3029 as a master.

The code I wrote to set up communication with the two slaves is as following:

/* Setup I2C for interface board */
  /* device handle */
  ADI_I2C_HANDLE i2cDevice;
  
  /* check set speed API */
  if(ADI_I2C_SUCCESS != adi_i2c_Open(0, ADI_I2C_MASTER, devMem, ADI_I2C_MEMORY_SIZE, &i2cDevice)){
    printf("I2C Not Open");
  }
  
  if(ADI_I2C_SUCCESS != adi_i2c_SetBitRate(i2cDevice, 100)){
    printf("I2C BitRate Not Set");  // top-end
  }
  
  if(ADI_I2C_SUCCESS != adi_i2c_SetHardwareAddress(i2cDevice, 0x20)){
    printf("I2C Addr Not Set");
  }
  
    /* Setup I2C for DAC */
  /* device handle */
  ADI_I2C_HANDLE i2cDeviceDAC;
  
  /* check set speed API */
  if(ADI_I2C_SUCCESS != adi_i2c_Open(0, ADI_I2C_MASTER, devMemDAC, ADI_I2C_MEMORY_SIZE, &i2cDeviceDAC)){
    printf("I2C Not Open");
  }
  
  if(ADI_I2C_SUCCESS != adi_i2c_SetBitRate(i2cDeviceDAC, 100)){
    printf("I2C BitRate Not Set");  // top-end
  }
  
  if(ADI_I2C_SUCCESS != adi_i2c_SetHardwareAddress(i2cDeviceDAC, 0x55)){
    printf("I2C Addr Not Set");
  }

The issue is, that even though I set up two different handles and set the address for each handle, the system will only write to the address defined last, even if I write to handle defined first.

For example:

This code adi_i2c_Write(i2cDeviceDAC, &i2cData, 1); will write to the same address as this code adi_i2c_Write(i2cDevice, &i2cData, 2);

Is there an issue in the way I define these handles and their individual addresses?

Thanks,

Andreas

Parents
  • It seems like the system can only work with one ADI_I2C_HANDLE at a time. Therefore it looks like I will have to run adi_i2c_SetHardwareAddress(i2cDevice, NEW_ADDRESS); every time I want to write data to a different IC on the bus.

    This seems more complex than just having a handle for each device (which I thought was the original idea behind the ADI_I2C_HANDLE).

    Thanks!

    Andreas

Reply
  • It seems like the system can only work with one ADI_I2C_HANDLE at a time. Therefore it looks like I will have to run adi_i2c_SetHardwareAddress(i2cDevice, NEW_ADDRESS); every time I want to write data to a different IC on the bus.

    This seems more complex than just having a handle for each device (which I thought was the original idea behind the ADI_I2C_HANDLE).

    Thanks!

    Andreas

Children