2025-09-30 7:16 PM
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?
2025-10-01 1:41 AM
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.
2025-10-01 2:08 PM
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.