2024-09-02 02:11 PM
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 ?
Solved! Go to Solution.
2024-09-04 05:58 AM
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.
2024-09-03 02:00 AM
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.
2024-09-03 02:08 AM
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
2024-09-03 03:45 AM
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.
2024-09-04 05:58 AM
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.
2024-09-04 07:18 AM
Hi Federica,
thanks for reply . I think I do more or less the same .
This is my pseudo code :
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 :
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.