cancel
Showing results for 
Search instead for 
Did you mean: 

implement pedometer on ISM330IS

apache
Associate II

Hi all,

we have a customer hardware with ISM330IS sensor on .

We want to implement a pedometer on it like in the ISM330DHCX. Is it possible ?

I followed the repo ism330is-pid/ism330is_reg.c at 413acfb51fd6f81a7449980a1caf286e37c909fe · STMicroelectronics/ism330is-pid (github.com) but it seems to not include it !

Instead I see it for ISM330DHCX (STMicroelectronics/ism330dhcx-pid: ism303dhcx platform independent driver based on Standard C language and compliant with MISRA standard (github.com)

 

Can I use that code too ?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @apache ,

 

Yes, you are on the right direction.

You can follow the official driver example here where the loading of the configuration is also done:

  /* Load ISPU configuration */
  for ( i = 0; i < (sizeof(ispu_conf) / sizeof(ucf_line_ext_t) ); i++ ) {
    switch(ispu_conf[i].op) {
    case MEMS_UCF_OP_DELAY:
      platform_delay(ispu_conf[i].data);
      break;
    case MEMS_UCF_OP_WRITE:
      lsm6dso16is_write_reg(&dev_ctx, ispu_conf[i].address, (uint8_t *)&ispu_conf[i].data, 1);
      break;
    }
  }

No problem using MCUs not from ST.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

5 REPLIES 5
Federica Bossi
ST Employee

Hi @apache ,

Unlike ISM330DHCX, the ISM330IS doesn't implement in the hardware the embedded function of  pedometer (step detector and step counter).

If you want to implement a pedometer you need to do it in the core.

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
apache
Associate II

Hi,

thanks a lot.

What you mean in the core ? I think the HW is more or less like ISM330DHCX and even more powerful.

How to implemement in the core ? have you same example ?

Thks

 

Hi ,

I saw this link here which seems to implement ISM330IS pedometer in the core (ispu-examples/ism330is_lsm6dso16is at master · STMicroelectronics/ispu-examples (github.com)) .

I have a custom MCU in my board, so do I have to downlad the pedometer.h file on the chip via I2C ?

I see the static const ucf_line_ext_t ispu_conf[] structure containg all the operation to do, Do I have to do so ? 

Of course Im going to  buy the dev kit but  I dont use ST MCU to drive the MEMS. 4

Anyway I need to validate the "production process" before I can go for production.

Can you help?

Thanks.

 

 

Hi @apache ,

 

Yes, you are on the right direction.

You can follow the official driver example here where the loading of the configuration is also done:

  /* Load ISPU configuration */
  for ( i = 0; i < (sizeof(ispu_conf) / sizeof(ucf_line_ext_t) ); i++ ) {
    switch(ispu_conf[i].op) {
    case MEMS_UCF_OP_DELAY:
      platform_delay(ispu_conf[i].data);
      break;
    case MEMS_UCF_OP_WRITE:
      lsm6dso16is_write_reg(&dev_ctx, ispu_conf[i].address, (uint8_t *)&ispu_conf[i].data, 1);
      break;
    }
  }

No problem using MCUs not from ST.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Federica,

thanks for reply . I think I do more or less the same .

This is my pseudo code :

  1. every time my FW start I enable the ISPU register address by writing "128" register on the 0x01H as per ISPU datasheet. 
  2. I Read back this value and correctly I have "128"
  3. I run more or less the same your code above in order to perform the I2C transaction and download the fw to the ISPU:

uint8_t initPedometer (){


uint8_t dataw[2];


uint32_t iteration = sizeof (ispu_conf) / 3;
uint32_t iterIsm;
for (iterIsm = 0; iterIsm < iteration; iterIsm++) {


dataw[0] = ispu_conf[iterIsm].address;
dataw[1] = ispu_conf[iterIsm].data;
if (ispu_conf[iterIsm].op == 1) {
if (I2C2_writeDelay((uint8_t)(ISPU_ADDRESS), dataw, 2)) {

return 1;

}
vTaskDelay(1); //even if I dont have to wait I wait 1 msec

} else if (ispu_conf[iterIsm].op == 2)
vTaskDelay(5); //wait 5 ms if operation is "delay"

}

return 0;
}

 

Please consider :

  • if this method goes wrong it returns 1 otherwise 0
  • Please consider Im not using your platform_write, platfomr_read since I think I dont need it , am i wrong ?

In addition is your 

 

sizeof(ucf_line_ext_t) equals to 3 ?

 

Once I have configured it I symply read 2 register starting from address 0x1C but I always get zero even if I move my board and make some steps:

 

while(1){

 readPEdometer();

vtaskDelay(3) ; //wait 3 sec

 

}

 

where my funciton is :

 

int16_t readPedometer(){

uint8_t ped=0X1C;
uint8_t result[2];
uint16_t pedL,pedH;
if (I2C2_readDelay((uint8_t)(ISPU_ADDRESS),&ped, 2, result, 2)==0){
pedL=(uint16_t)result[0];
pedH=(uint16_t)result[1];
return (pedH<<8)|pedL;

}
return -1;

}

 

Is this flow good or am I doing something wrong?

 

Thanks a lot.