Skip to main content
Visitor II
April 18, 2024
Solved

Bug in LSM6DSV16X driver v3.0.0, COUNTER_BDR_REG1/COUNTER_BDR_REG2 configured wrong

  • April 18, 2024
  • 2 replies
  • 1696 views

Hello,

I just wanted to inform you that there is a bug in the ST driver for the LSM6DSV16X v3.0.0, available on Github.

Function lsm6dsv16x_fifo_batch_counter_threshold_set is wrongly setting the 2 register values, and for COUNTER_BDR_REG1 it is not ensuring that other bit fields are not changed.

I stumbled upon this after some time trying to get the BDR counter threshold interrupt to work in a prototype, and thought to share it here.

I changed that function implementation to the code below (basically a copy from the LSM6DSOX driver), and it works fine now:

int32_t lsm6dsv16x_fifo_batch_counter_threshold_set(const stmdev_ctx_t *ctx,
 uint16_t val)
{
 lsm6dsv16x_counter_bdr_reg1_t counter_bdr_reg1;
 lsm6dsv16x_counter_bdr_reg2_t counter_bdr_reg2;
 int32_t ret;

 ret = lsm6dsv16x_read_reg(ctx, LSM6DSV16X_COUNTER_BDR_REG1,
 (uint8_t *)&counter_bdr_reg1, 1);

 if (ret == 0)
 {
 counter_bdr_reg2.cnt_bdr_th = 0x00FFU & (uint8_t)val;
 counter_bdr_reg1.cnt_bdr_th = (uint8_t)(0x0700U & val) >> 8;
 ret = lsm6dsv16x_write_reg(ctx, LSM6DSV16X_COUNTER_BDR_REG1,
 (uint8_t *)&counter_bdr_reg1, 1);
 }

 if (ret == 0)
 {
 ret = lsm6dsv16x_write_reg(ctx, LSM6DSV16X_COUNTER_BDR_REG2,
 (uint8_t *)&counter_bdr_reg2, 1);
 }

 return ret;
}

Regards,

Rafael

 

    This topic has been closed for replies.
    Best answer by Federica Bossi

    Hi @rafael_daciuk ,

    Can you try this new release and let me know if you solve?

     

    2 replies

    Technical Moderator
    May 2, 2024

    Hi @rafael_daciuk ,

    Thank you for pointing that out, you are right. The team is working on fixing the bug as soon as possible, I will let you know as soon as we release a new version with the fix.

    Visitor II
    May 2, 2024

    Hi Federica,

    Glad to know you are already working on a fix.

    I'm looking forward to getting the updated driver code.

    Thank you,

    Rafael

    Technical Moderator
    May 2, 2024

    Hi @rafael_daciuk ,

    Can you try this new release and let me know if you solve?

     

    Visitor II
    May 7, 2024

    Hi @Federica Bossi,

    This new version of the driver worked for me.

    Thank you for the update.

    Regards,

    Rafael