cancel
Showing results for 
Search instead for 
Did you mean: 

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?

AK.08
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
AK.08
Associate III

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

View solution in original post

20 REPLIES 20
Eleon BORLINI
ST Employee

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.08
Associate III

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

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

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

ok thank you @Community member​ 

And did you try with the other suggestions? Could you share your sample code?

-Eleon

I have tried all the suggestions and I have attached the sample code of the function.

is there any condition to be taken care? for setting that register.

Also, I am trying to get data overrun interrupt on INT1. I am reading the STAT register and it has Data overrun flag set, but that isn't generating the interrupt.

can you suggest me a way to read the interrupt?

I am able to get Interrupt now but I am still unable to write into Register 1 and register 3. If I write them in an infinite loop, they get written one time and then they are automatically set to 0x00 and don't write any values. I have tried all your suggestions. I am still unable. Please guide.

AK.08
Associate III

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

Eleon BORLINI
ST Employee

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