cancel
Showing results for 
Search instead for 
Did you mean: 

lsm6dso sensor not work right in multithread mode

JXiao.1
Associate II

I am working with lsm6dso sensor for a watch. At the beginning, I am using ​the follwoing function to get steps in the register. It works in a while loop and can work rightly.

int32_t lsm6dso_number_of_steps_get(stmdev_ctx_t *ctx, uint8_t *buff)
{
  int32_t ret;
 
  ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK);
  if (ret == 0) {
    ret = lsm6dso_read_reg(ctx, LSM6DSO_STEP_COUNTER_L, buff, 2);
  }
  if (ret == 0) {
    ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
  }
  return ret;
}

Then I want to put this function in another thread. But it seems to work right. It works for a while at first, but after running for some time, the number of steps will automatically reset to zero.

I want to know under what condition will the sensor reset. Does the multithread affect its function?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @JXiao.1​ ,

sure you can set the LSM6DSO device in power down mode or in low power mode by code.

For the power down, you can just set all the configuration registers to 00h: the device will consume about 3μA.

In the ultra-low power mode case, enabled by setting the proper ODR_XL bits of CTRL1_XL (10h) register and the gyroscope in Power-Down mode, the device will consume 4.4 μA in the lowest ODR case (1.6Hz). See the datasheet, p.50.

See also the table 9 in the AN5192 application note p.15 an for further details on the current consumption levels.

You can also decide to wake up your device (so recovering it from sleep more to normal mode) only when an external mechanical event exceeds a predefined threshold: the Wake-up interrupt feature is described in the same application note, p.42. You can also find a C example conde on Github repository (lsm6dso_wake_up.c).

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.

-Eleon

View solution in original post

3 REPLIES 3
Eleon BORLINI
ST Employee

Hi @JXiao.1​ ,

first, I'm glad you managed to make the step counter with LSM6DSO working.

About the current issue, the only way the chip could reset is the case you deliberately enabled the SW_RESET bit of CTRL3_C (12h) register (datasheet p.53) but it seems not to be the case, or the Vdd falls below the minimum value (i.e. 1.71V). I'm wondering if there could be some issue coming from the multithread operation, for example due to interrupt handlers: is the hardware connection compliant with the connection suggested in the datasheet p.35?

0693W000008x2neQAA.png 

Moreover, do you have the possibility to acquire (e.g. with a scope) the Vdd line during the multithread operation? Can you also check whether the configuration registers' values are 00h just after the step counter resets to 0?

-Eleon

Thank you for your anwser.

Now the ​reset bug can't be duplicated and I can't make sure when it can happen. I will obeserve more.

And I have a question about sensor setting. Can I use code to control the power mode of sensor? Because I want to set the sensor not work in some conditions to save power. Or I need to set pins to zero to turn off the sensor?​

Hi @JXiao.1​ ,

sure you can set the LSM6DSO device in power down mode or in low power mode by code.

For the power down, you can just set all the configuration registers to 00h: the device will consume about 3μA.

In the ultra-low power mode case, enabled by setting the proper ODR_XL bits of CTRL1_XL (10h) register and the gyroscope in Power-Down mode, the device will consume 4.4 μA in the lowest ODR case (1.6Hz). See the datasheet, p.50.

See also the table 9 in the AN5192 application note p.15 an for further details on the current consumption levels.

You can also decide to wake up your device (so recovering it from sleep more to normal mode) only when an external mechanical event exceeds a predefined threshold: the Wake-up interrupt feature is described in the same application note, p.42. You can also find a C example conde on Github repository (lsm6dso_wake_up.c).

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.

-Eleon