cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DS0X STEP COUNT READ BUG

PPill.1
Associate

After loading a new decission tree for the Machine Learning Core the behaviour of the Step count registers of the pedometer changed.

I must note that none of the code changed, just the register mapping corresponding the decision tree loaded to the MLC. With the previous setup the value was correctly read, the LSM6DSOX_STEP_COUNTER_L is copied into the lower part of the variable, and LSM6DSOX_STEP_COUNTER_H on the higher part.

But after the new tree was loaded, LSM6DSOX_STEP_COUNTER_L gets read on the lower part but for the higher part of the variable LSM6DSOX_STEP_COUNTER_L gets written again instead of LSM6DSOX_STEP_COUNTER_H.

To fix this we had to change the code from lsm6dsox_reg.c that reads this values from the registers,

Previous code without fix:

int32_t lsm6dsox_number_of_steps_get(stmdev_ctx_t *ctx, uint8_t *buff)
{
  int32_t ret;
 
  ret = lsm6dsox_mem_bank_set(ctx, LSM6DSOX_EMBEDDED_FUNC_BANK);
  if (ret == 0) {
    ret = lsm6dsox_read_reg(ctx, LSM6DSOX_STEP_COUNTER_L, buff, 2);
  }
 
  if (ret == 0) {
    ret = lsm6dsox_mem_bank_set(ctx, LSM6DSOX_USER_BANK);
  }
  return ret;
}

Reading both LSM6DSOX_STEP_COUNTER_L and LSM6DSOX_STEP_COUNTER_H sepparately fixed the issue:

int32_t lsm6dsox_number_of_steps_get(stmdev_ctx_t *ctx, uint8_t *buff)
{
  int32_t ret;
 
  ret = lsm6dsox_mem_bank_set(ctx, LSM6DSOX_EMBEDDED_FUNC_BANK);
  if (ret == 0) {
    ret = lsm6dsox_read_reg(ctx, LSM6DSOX_STEP_COUNTER_L, buff, 1);
  }
  if (ret == 0) {
      ret = lsm6dsox_read_reg(ctx, LSM6DSOX_STEP_COUNTER_H, buff+1, 1);
    }
  if (ret == 0) {
    ret = lsm6dsox_mem_bank_set(ctx, LSM6DSOX_USER_BANK);
  }
  return ret;
}

Can somebody explain this bug or unexpected change of behaviour?

None of the registers for the pedometer configuration were changed.

Thanks in advance

1 REPLY 1
Eleon BORLINI
ST Employee

Hi @Pedro Pillado García-Gesto​ ,

The difference between the two codes you shared is only in the readings (two singles or one multiple), it seems strange you fixed the problem that way.

Can you please share the full configuration procedure you are using and the writings you do?

-Eleon