Skip to main content
Visitor II
December 3, 2020
Solved

Hi, I want to implement the wake up state machine of Lis3dsh. I studied the application note and tried to set the registers as needed. I am unable to set 0x01 to Control Register 1. How can I Set it?

  • December 3, 2020
  • 4 replies
  • 3169 views

Since the default value of the register is not changing, the state machine is not enabling and thus, I am not getting any interrupt.

    This topic has been closed for replies.
    Best answer by AK.08

    Hi, I have fixed the isuse and the state machine works fine. It was some problem with I2C. Thak you for your support throughout :)

    4 replies

    ST Employee
    December 3, 2020

    Hi @Community member​ ,

    is the CTRL1_REG the only register you cannot set (i.e. you cannot write the 01h value inside it)? Did you check if you are at least able to read the WHO_AM_I (0Fh) reg? And, if so, are you able for example to set the CTRL_REG2 (22h), same bit, which is dedicated to the State machine N.2?

    I suggest you to check the basic device configuration code that you can find in the lis3dsh_read_data_polling.c

    -Eleon

    AK.08Author
    Visitor II
    December 4, 2020

    Hi,

    I have tried reading the WHO_AM_I register and I could read 3F. I could successfully set Control Registers 3, 4, 5,6 according to the "Wakeup" State machine. As per your suggestion, I tried setting the same bit in CTRL2_REG, but that too is not getting set. On reading the register 1 and 2 after writing 0x01 to them, the read value was 0x00. Please help me proceed

    ST Employee
    December 4, 2020

    So strange you are not able to read/write a single register... er even a single bit... Can you please try to write another bit of that register, or run two dummies write commands before writing CTRL1_REG andCTRL2_REG, or again try the configuration procedure on another LIS3DSH device, if it's possible for you?

    As a side note, if you are using the Github drivers for the LIS3DSH (lis3dsh_reg.c), and especially the below init_set function, you have to add the first two ctrl registers, defined in the lis3dsh_reg.h.

    int32_t lis3dsh_init_set(stmdev_ctx_t *ctx, lis3dsh_init_t val)
    {
     lis3dsh_ctrl_reg3_t ctrl_reg3;
     lis3dsh_ctrl_reg4_t ctrl_reg4;
     lis3dsh_ctrl_reg6_t ctrl_reg6;
     int32_t ret;
    ...

    -Eleon

    AK.08Author
    Visitor II
    December 4, 2020

    I have tried dummy write commands before writing into Register 1 and also other bits. Still no luck.

    AK.08Author
    Visitor II
    December 9, 2020

    Hi, Can you please guide me to solve this issue. its been 2 days and I am clueless.

    ST Employee
    December 9, 2020

    No clue so far from my side, unfortunately... did you try also with a different device, if you had the possibility?

    In your last comment you say you cannot write Reg1 and Reg3, but in a previous comment it was Reg1 and Reg2... can you please confirm?

    -Eleon

    AK.08Author
    Visitor II
    December 10, 2020

    Unfortunately, trying with another device is not really possible, specially when all the other registers are working properly. I will try if something is possible.

    I have trouble writing into Registers 1 and 3. register 2 is not a part of the wake up state machine, so I need not use it, but I tried writing to it with your suggestion. That doesn't work either.