cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to go into single trigger and continuous mode on LIS2MDL

IoTV_WilliamC
Associate

When I try to set the LIS2MDL's operation mode from IDLE to CONTINUOUS or SINGLE_TRIGGER mode, the register values in CFG_REG_A that I already set prior (including comp_temp_en) gets reset to default including the operation mode when I check the register after a 7ms delay. I am using functions from the lis2mdl_reg.c/h files and have read values on hardware debug mode and on the SDA line. I have checked that 3V3 does not drop out and I2C communications look expected. Does anyone have any insight into what could be causing this?

2 REPLIES 2
Federica Bossi
ST Employee

Hi @IoTV_WilliamC ,

It is suggested to always perform read-modify-write on CFG_REG_A to avoid clearing other bits.

CFG_REG_A is a multi-bit control register: writing to this register overwrites all bits at once.

If your write commands only set the operation mode bits but do not preserve other bits (like comp_temp_en), those bits will be cleared to default.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Federica,

As mentioned above, I use functions from lis2mdl_reg.c, which do read the register and OR the value which the function is changing. When I change the operation mode bits to SINGLE TRIGGER or CONTINUOUS, the register resets (without going to either mode), but if I change the operation mode bits from 3 to 2 (default IDLE mode to other IDLE mode) the value does change when I read the register again.