Other Parts Discussed in Thread: PCF8574
Tool/software:
I am having issue with programing new slave address for DAC53701 chips as 3 chips are present on the same I2C bus. I want to program 2 chips to alternate slave address of 0x49 and 0x4a. 0x48 being the default address which I keep for the third chip.
Pins PCF8574_PIN_3, PCF8574_PIN_4 are GPI pins of the two devices, the GPI of third pin is always LOW during programing.
Here is my program to program the first chip i call PULSE device, DAC53701_I2C_ADDRESS_BROADCAST is 0x47
// set GPI pin low for all devices. for the backup device, by default the GPI pin is low so do nothing
pcf8574_write(hi2c, PCF8574_PIN_3, PCF8574_PIN_LEVEL_LOW);
pcf8574_write(hi2c, PCF8574_PIN_4, PCF8574_PIN_LEVEL_LOW);
// lets program PULSE device
pcf8574_write(hi2c, PCF8574_PIN_3, PCF8574_PIN_LEVEL_HIGH);
i2c_driver_mutex_wait();
buf[0] = REG_CONFIG2;
buf[1] = 0x38;
buf[2] = 0x00;
if(i2c_driver_transmit_it(hi2c, DAC53701_I2C_ADDRESS_BROADCAST , &buf[0], 3) != HAL_OK)
{
Error_Handler();
}
buf[0] = REG_TRIGGER;
buf[1] = 0x04;
buf[2] = 0x00;
if(i2c_driver_transmit_it(hi2c, DAC53701_I2C_ADDRESS_BROADCAST , &buf[0], 3) != HAL_OK)
{
Error_Handler();
}
i2c_driver_mutex_release();
i2c_driver_mutex_wait();
buf[0] = REG_CONFIG2;
buf[1] = 0x40;
buf[2] = 0x00;
if(i2c_driver_transmit_it(hi2c, DAC53701_I2C_ADDRESS_BROADCAST , &buf[0], 3) != HAL_OK)
{
Error_Handler();
}
i2c_driver_mutex_release();
pcf8574_write(hi2c, PCF8574_PIN_3, PCF8574_PIN_LEVEL_LOW);
address_modified = true;
}
if (address_modified)
{
i2c_driver_mutex_wait();
buf[0] = REG_TRIGGER;
buf[1] = 0x00;
buf[2] = 0x00;
if(i2c_driver_transmit_it(hi2c, DAC53701_I2C_ADDRESS_BROADCAST , &buf[0], 3) != HAL_OK)
{
Error_Handler();
}
buf[0] = REG_CONFIG2;
buf[1] = 0x00;
buf[2] = 0x00;
if(i2c_driver_transmit_it(hi2c, DAC53701_I2C_ADDRESS_BROADCAST , &buf[0], 3) != HAL_OK)
{
Error_Handler();
}
buf[0] = REG_TRIGGER;
buf[1] = 0x00;
buf[2] = 0x10;
if(i2c_driver_transmit_it(hi2c, DAC53701_I2C_ADDRESS_BROADCAST , &buf[0], 3) != HAL_OK)
{
Error_Handler();
}
i2c_driver_mutex_release();
Let me know if I am doing anything wrong.
Thanks