cancel
Showing results for 
Search instead for 
Did you mean: 

After enabling the sensor hub I2C master bit in MASTER_CONFIG (1Ah) register of STEVAL-MKI182v2(ISM330DLC) I'm not able to read through ISM330DLC register for eg. 0x0f(WHO_AM_I).

APatel.13
Associate II

STM NUCLEO-L4R5ZI-P is used to interface the  STEVAL-MKI182v2(ISM330DLC) .

4 REPLIES 4
TBomb.1
Senior II

Hi,

Please consider this sentence:

In order to enable the embedded functionalities of the ISM330DLC , the FUNC_EN bit of the CTRL10_C register has to be set to 1; after enabling the embedded functionalities, the MASTER_CONFIG register has to be used for the configuration of the I2C master interface.

Not sure that, if the ISM330DLC is configured as I2C master, he cannot be treated as a slave from the application processor.

See for example this example code on Github: https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dso_STdC/examples/lsm6dso_sensor_hub_lps22hh.c

\Tom

APatel.13
Associate II

Hi TBomb.1,

Thank you for the reply.

I followed the same process as per below link from Github: 

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dso_STdC/examples/lsm6dso_sensor_hub_lps22hh.c

I tried to read device ID of LIS2MDL sensor and program get stuck inside below highlighted snippet of "ism330dlc_read_lis2mdl_cx" function and it seems that trigger flag never changed.

static int32_t ism330dlc_read_lis2mdl_cx(void *ctx, uint8_t reg,

                    uint8_t *data, uint16_t len)

{

ism330dlc_sh_cfg_read_t sh_cfg_read;

int32_t ret;

ism330dlc_func_src1_t master_status;

/* Disable accelerometer. */

ret = ism330dlc_xl_data_rate_set(&ag_ctx, ISM330DLC_XL_ODR_OFF);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

/* Configure Sensor Hub to read LIS2MDL. */

sh_cfg_read.slv_add = (LIS2MDL_I2C_ADD & 0xFEU) >> 1; /* 7bit I2C address */

sh_cfg_read.slv_subadd = reg;

sh_cfg_read.slv_len = len;

ret = ism330dlc_sh_slv0_cfg_read(&ag_ctx, &sh_cfg_read);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

/* Configure number of slave connected to master I2C */

ret = ism330dlc_sh_num_of_dev_connected_set(&ag_ctx, ISM330DLC_SLV_0);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

/* Enable I2C Master. */

ret = ism330dlc_sh_master_set(&ag_ctx, PROPERTY_ENABLE);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

/* Enable accelerometer to trigger Sensor Hub operation. */

ism330dlc_xl_data_rate_set(&ag_ctx, ISM330DLC_XL_ODR_12Hz5);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

/* Get XL raw data */

ret = ism330dlc_acceleration_raw_get(&ag_ctx, &data_raw_acceleration.i16bit);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

/* Wait for XL(trigger) flag set. */

do {

HAL_Delay(20);

ism330dlc_xl_flag_data_ready_get(&ag_ctx, &drdy);

} while (!drdy);

/* Wait Sensor Hub operation flag set. */

do {

HAL_Delay(20);

ism330dlc_read_reg(&ag_ctx, ISM330DLC_FUNC_SRC1, (uint8_t *)&master_status, 1);

} while (!master_status.sensorhub_end_op);

/* Disable I2C master */

ret = ism330dlc_sh_master_set(&ag_ctx, PROPERTY_DISABLE);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

/* Disable XL(trigger). */

ret = ism330dlc_xl_data_rate_set(&ag_ctx, ISM330DLC_XL_ODR_OFF);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

/* Read SensorHub registers. */

ret = ism330dlc_read_reg(&ag_ctx, ISM330DLC_SENSORHUB1_REG, data, len);

if(ret != ISM330DLC_OK)

return ISM330DLC_ERROR;

return ret;

}

For your information :

  • Evaluation board used : NUCLEO-L4R5-ZI-P
  • ISM330DLC sensor used as a master I2C
  • LIS2MDL connected as I2C slave.

Kindly suggest further how to read device id and data from LIS2MDL.

regards,

Ankur Patel

JWoeb.1
Associate II

@APatel.13 Hi, I am currently having the same problem that I replaced a LSM6DSL ( connected via SDx, SCx to a LIS3MDL compass ) with a ISM330DLC. But the sensorhub communication now does not work anymore. After starting a transfer by reenableing the Accelerometer the SENSORHUB_END_OP Bit in the FUNC_SRC1 register stays 0.

I measured the SDx and SCx pins and they remain at 1.8V at all times.

How did you solve this problem?

JWoeb.1
Associate II

@Eleon BORLINI

Hi, is there any example on how to use the sensor-hub functionality of the ISM330DLC specifically? The examples for LSM6DSL don't seem to work. I guess it has something to do with the fact, that ISM330DLC has the additional operation Modes 3 & 4 which LSM6DSL did not have which also use the SDx and SCx pins but I did not enable these modes.

Thanks