2020-12-16 06:47 AM
This pedometer function can count steps after the first ten steps. The first ten steps is defalt and the application note said it can be change other value. I have found I should set up ****_DEB_STEPS_CONF register. But I don't know how to do that. I just found the register address in the code but there is no value for change. How can I set it?
Solved! Go to Solution.
2020-12-21 02:22 AM
Hi @JXiao.1 ,
you have to change the content of the DEB_STEP[7:0] bits of the ****_DEB_STEPS_CONF register to change the number of steps. Please note that to access this particular register, and in general all the registers of the embedded functions, you have to write a particular set of commands to access a memory page that is not the default one: you can follow the indications described in the datasheet, p. 125:
Write procedure example:
Example: write value 06h register (meaning 6 initial steps) at address 84h (****_DEB_STEPS_CONF) in Page 1
1. Write bit FUNC_CFG_EN = 1 in FUNC_CFG_ACCESS (01h) // Enable access to embedded functions registers
2. Write bit PAGE_WRITE = 1 in PAGE_RW (17h) register // Select write operation mode
3. Write 0001 in PAGE_SEL[3:0] field of register PAGE_SEL (02h) // Select page 1
4. Write 84h in PAGE_ADDR register (08h) // Set address
5. Write 06h in PAGE_DATA register (09h) // Set value to be written
6. Write bit PAGE_WRITE = 0 in PAGE_RW (17h) register // Write operation disabled
7. Write bit FUNC_CFG_EN = 0 in FUNC_CFG_ACCESS (01h) // Disable access to embedded functions registers
Please let me know if you can manage this particular "Page section" R/W in your code.
-Eleon
2020-12-17 08:24 AM
Hi @JXiao.1 ,
can you please share the sample code / function you are using? But yes, as stated in the app note:
The number of debounce steps can be modified through the DEB_STEP[7:0] bits of the ****_DEB_STEPS_CONF register in the embedded advanced features registers: basically, it corresponds to the minimum number of steps to be detected before the first step counter increment. 1 LSB of this field corresponds to 1 step, the default value is 10 steps. The debounce functionality restarts after around 1.2 s of device inactivity.
so you can change the content of the register to reduce the initial debounce steps (1LSB = 1step).
For an example of the pedometer function configuration, you can refer to the Github drivers for the LSM6DSOX device (same as LSM6DSO for this embedded function), and in particular to the lsm6dsox_pedometer.c and the lsm6dsox_reg.h. The specific variable adn function are:
#define LSM6DSOX_****_DEB_STEPS_CONF 0x184U
int32_t lsm6dsox_****_debounce_steps_set(stmdev_ctx_t *ctx,
uint8_t *buff);
Please let me know if these indications can help you.
-Eleon
2020-12-18 01:39 AM
This is my using pedometer code in lsm6dso_reg.c. I think I should use lsm6dso_****_debounce_steps_set function but not sure. Should I use it in the main file to set the debounce step?
At the beginnning, I think I can set the debuonce step number directly in the default file. But I found "#define LSM6DSO_****_DEB_STEPS_CONF 0x184U" is just an address. It can't change the value.
/**
* @brief Enable pedometer algorithm.[set]
*
* @param ctx read / write interface definitions
* @param val turn on and configure pedometer
*
*/
int32_t lsm6dso_****_sens_set(stmdev_ctx_t *ctx, lsm6dso_****_md_t val)
{
lsm6dso_emb_func_en_a_t emb_func_en_a;
lsm6dso_emb_func_en_b_t emb_func_en_b;
lsm6dso_****_cmd_reg_t ****_cmd_reg;
int32_t ret;
ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_****_CMD_REG,
(uint8_t*)&****_cmd_reg);
if (ret == 0) {
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK);
}
if (ret == 0) {
ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A,
(uint8_t*)&emb_func_en_a, 1);
}
if (ret == 0) {
ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B,
(uint8_t*)&emb_func_en_b, 1);
emb_func_en_a.****_en = (uint8_t)val & 0x01U;
emb_func_en_b.****_adv_en = ((uint8_t)val & 0x02U)>>1;
****_cmd_reg.fp_rejection_en = ((uint8_t)val & 0x10U)>>4;
****_cmd_reg.ad_det_en = ((uint8_t)val & 0x20U)>>5;
}
if (ret == 0) {
ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_A,
(uint8_t*)&emb_func_en_a, 1);
}
if (ret == 0) {
ret = lsm6dso_write_reg(ctx, LSM6DSO_EMB_FUNC_EN_B,
(uint8_t*)&emb_func_en_b, 1);
}
if (ret == 0) {
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
}
if (ret == 0) {
ret = lsm6dso_ln_pg_write_byte(ctx, LSM6DSO_****_CMD_REG,
(uint8_t*)&****_cmd_reg);
}
return ret;
}
/**
* @brief Enable pedometer algorithm.[get]
*
* @param ctx read / write interface definitions
* @param val turn on and configure pedometer
*
*/
int32_t lsm6dso_****_sens_get(stmdev_ctx_t *ctx, lsm6dso_****_md_t *val)
{
lsm6dso_emb_func_en_a_t emb_func_en_a;
lsm6dso_emb_func_en_b_t emb_func_en_b;
lsm6dso_****_cmd_reg_t ****_cmd_reg;
int32_t ret;
ret = lsm6dso_ln_pg_read_byte(ctx, LSM6DSO_****_CMD_REG,
(uint8_t*)&****_cmd_reg);
if (ret == 0) {
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK);
}
if (ret == 0) {
ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_A,
(uint8_t*)&emb_func_en_a, 1);
}
if (ret == 0) {
ret = lsm6dso_read_reg(ctx, LSM6DSO_EMB_FUNC_EN_B,
(uint8_t*)&emb_func_en_b, 1);
}
if (ret == 0) {
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
}
switch ( (****_cmd_reg.ad_det_en
2020-12-18 01:40 AM
Thank you for your answer. I have using lsm6dso_****_debounce_steps_set function to archieve my goal initially. But there is still a problem that the sensitivity of the sensor is high. Some actions will be considered walking. Can I change the sensitivity of the sensor? Or this is related to the algorithm sensor.
I am also confused about the ****_SC_DEKTAT_L and ****_SC_DEKTAT_H function. I have tried to change their value but it will make no interrupt output. Hope you can explain it.
2020-12-18 01:52 AM
The code of pedometer is too much and it can't show all. I show you all the function names.
lsm6dso_****_sens_set(stmdev_ctx_t *ctx, lsm6dso_****_md_t val)
lsm6dso_****_sens_get(stmdev_ctx_t *ctx, lsm6dso_****_md_t *val)
lsm6dso_****_step_detect_get(stmdev_ctx_t *ctx, uint8_t *val)
lsm6dso_****_debounce_steps_set(stmdev_ctx_t *ctx, uint8_t *buff)
lsm6dso_****_debounce_steps_get(stmdev_ctx_t *ctx, uint8_t *buff)
lsm6dso_****_steps_period_set(stmdev_ctx_t *ctx, uint8_t *buff)
lsm6dso_****_steps_period_get(stmdev_ctx_t *ctx, uint8_t *buff)
lsm6dso_****_int_mode_set(stmdev_ctx_t *ctx, lsm6dso_carry_count_en_t val)
lsm6dso_****_int_mode_get(stmdev_ctx_t *ctx, lsm6dso_carry_count_en_t *val)
2020-12-18 03:12 AM
.
2020-12-21 02:22 AM
Hi @JXiao.1 ,
you have to change the content of the DEB_STEP[7:0] bits of the ****_DEB_STEPS_CONF register to change the number of steps. Please note that to access this particular register, and in general all the registers of the embedded functions, you have to write a particular set of commands to access a memory page that is not the default one: you can follow the indications described in the datasheet, p. 125:
Write procedure example:
Example: write value 06h register (meaning 6 initial steps) at address 84h (****_DEB_STEPS_CONF) in Page 1
1. Write bit FUNC_CFG_EN = 1 in FUNC_CFG_ACCESS (01h) // Enable access to embedded functions registers
2. Write bit PAGE_WRITE = 1 in PAGE_RW (17h) register // Select write operation mode
3. Write 0001 in PAGE_SEL[3:0] field of register PAGE_SEL (02h) // Select page 1
4. Write 84h in PAGE_ADDR register (08h) // Set address
5. Write 06h in PAGE_DATA register (09h) // Set value to be written
6. Write bit PAGE_WRITE = 0 in PAGE_RW (17h) register // Write operation disabled
7. Write bit FUNC_CFG_EN = 0 in FUNC_CFG_ACCESS (01h) // Disable access to embedded functions registers
Please let me know if you can manage this particular "Page section" R/W in your code.
-Eleon
2020-12-21 02:26 AM
Now I can write a new value to ****_DEB_STEPS_CONF. And I want to set the sensitivity of the sensor. I didn't find the information about it. Can you tell me how to set it?
2020-12-21 02:28 AM
I'll refer to the other question you posted, and will close this one.
-Eleon