cancel
Showing results for 
Search instead for 
Did you mean: 

Sensor hub no I2C communication using IIS2ILCX

KoCT
Associate II

Hello,

I use the STEVAL-MKI209V1K with the IIS2ILCX sensor. I am trying to get the IIS2ILCX communicating with a second IIS2ILCX via sensor hub. The master sensor is connected to my MCU via SPI. Please find my „schematic“ and the configuration code below.

My problem is, that I cannot observe any I2C communication between the sensors. My oscilloscope just shows 3.4 V for each SCL and SDA. What could be wrong?

I would greatly appreciate any suggestions.

 

Additional information: i want to read the slaves data triggered by DRDY-Interrupt to get synchronized data of both sensors.

accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FUNC_CFG_ACCESS, 0x00);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FIFO_CTRL1, 0x7F);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FIFO_CTRL2, 0x00);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FIFO_CTRL3, 0x07);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FIFO_CTRL4, 0x01);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_INT1_CTRL, 0x00);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL1_XL, 0x70);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL3_C, 0x44); 
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL4_C, 0x04);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL9_XL, 0x00);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_MD1_CFG, 0x00);

// shub config
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FUNC_CFG_ACCESS, 0x80);  // Activate access to shub registers
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_ADD, 0x68);      // I2C address of sensor 2
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_SUBADDR, ACCEL_IIS2ILCX_REG_ADDR_CTRL1_XL);  // set to 2 g and 833 Hz
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_DATAWRITE_SLV0, 0x7C);// power-down, 2 g
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_ADD, 0x68);      // I2C address of sensor 2
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_SUBADDR, ACCEL_IIS2ILCX_REG_ADDR_INT2_CTRL);  // set to 2 g and 833 Hz
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_DATAWRITE_SLV0, 0x01);// power-down, 2 g
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_ADD, 0x68);      // I2C address of sensor 2
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_SUBADDR, 0x28);  // OUTX_L_A register //! could be changed to 0x2A for Y-axis
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_CONFIG, 0x0A);   // SHUB-ODR = 0 Hz, FIFO data batching enabled, 2 read operations
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SHUB_MASTER_CONFIG, 0x24); // MASTER_ON, 1 ext sensor, START CONFIG
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FUNC_CFG_ACCESS, 0x00);  // deactivate shub register access

 

3 REPLIES 3
TDK
Super User

Do any slave addresses respond to HAL_I2C_IsDeviceReady? Note that HAL expects the 7-bit address to be left-shifted by 1 bit.

If you feel a post has answered your question, please click "Accept as Solution".
KoCT
Associate II

The communication with the "master" sensor via SPI works fine. I am using an ESP32. Therefore I provide my write function here:

static bool accelerometer_write_register(accel_iis2ilcx_t *accel, uint8_t address, uint8_t reg_value) 
{
	unsigned char write_buf[2];
	write_buf[0] = address & ~(1 << 7);
	write_buf[1] = reg_value;

	return spi_interface_write(accel->spi_device, write_buf, 2);
}

I guess that the sensor hub i2c is not directly accessible for me, right? 

KoCT
Associate II

After having found AN5763 chapter 7 (Mode 2 - sensor hub mode) I adjusted my configuration. Still there is no traffic on the I2C...

 

uint8_t fifo_ctrl1 = 0x7F;
uint8_t fifo_ctrl2 = 0x00;
uint8_t fifo_ctrl3 = 0x07;
uint8_t fifo_ctrl4 = FIFO_FIFO_MODE;
uint8_t int1_ctrl = 0x00;
uint8_t ctrl6_c = 0x80;                 // TRIG_EN on INT2
uint8_t ctrl1_xl = 0x70;            // 833 Hz @ 0,5 g
uint8_t ctrl3_c = 0x44;
uint8_t ctrl4_c = 0x04; // I2C disabled
uint8_t ctrl9_xl = 0xF2;

accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FUNC_CFG_ACCESS, 0x00);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FIFO_CTRL1, fifo_ctrl1);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FIFO_CTRL2, fifo_ctrl2);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FIFO_CTRL3, fifo_ctrl3);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FIFO_CTRL4, fifo_ctrl4);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_INT1_CTRL, int1_ctrl);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL1_XL, ctrl1_xl);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL3_C, ctrl3_c); 
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL4_C, ctrl4_c);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL6_C, ctrl6_c);
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_CTRL9_XL, ctrl9_xl);

// Sensor hub
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FUNC_CFG_ACCESS, 0x80);
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_ADD, 0x68);
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_SUBADDR, ACCEL_IIS2ILCX_REG_ADDR_CTRL1_XL);
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_DATAWRITE_SLV0, 0x7C);
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SHUB_MASTER_CONFIG, 0x4C) // SHUB_PU_EN, MASTER_ON, 1 ext sensor, START CONFIG = false
shub_wait_for_write_done(accel); // polling read of MASTER STATUS until WR_ONCE_DONE                                                      
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_ADD, 0x68);
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_SUBADDR, ACCEL_IIS2ILCX_REG_ADDR_INT2_CTRL);  
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_DATAWRITE_SLV0, 0x01);// DRDY
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SHUB_MASTER_CONFIG, 0x4C); // SHUB_PU_EN, MASTER_ON, 1 ext sensor, START CONFIG = false
shub_wait_for_write_done(accel);                                                      // 

accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV0_ADD, (0x68 << 1) | 0x01);
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV1_SUBADDR, ACCEL_IIS2ILCX_REG_ADDR_OUTX_L_A);
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SLV1_CONFIG, 0x0A); // BATCH_EXT_SENS1_EN & 2 read ops
accelerometer_write_register(accel, ACCEL_IIS2ICLX_REG_ADDR_SHUB_MASTER_CONFIG, 0x6C); // SHUB_PU_EN, MASTER_ON, 1 ext sensor, START CONFIG
accelerometer_write_register(accel, ACCEL_IIS2ILCX_REG_ADDR_FUNC_CFG_ACCESS, 0x00);