2022-09-30 07:22 AM
Solved! Go to Solution.
2022-10-07 01:18 AM
Got it to work now!
Think it might have been the magnetometer (LIS2MDL) connected to the same SPI-bus that was sending out some garbage. Saw that when CS is high the sensors are configured for I2C.
When I configured the magnetometer sensor in my device tree and enabled the LIS2MDL driver in Zephyr OS it is working fine.
But I have another question regarding the accelerometer LIS2DH12.
I'm trying to configure the interrupt, to trigger when e.g. the x-axis goes above a threshold value. Not sure what to put in the INT1_THS register?
and, in the output registers (OUT_X_L and OUT_X_H) what's the value/unit? is it in g, mg or m/s2?
Looked in the datasheet and looks like when the sensor is configured in Normal Mode with +-2g sensitivity, each digit is equal to 4mg?
So if I read out for example the raw value '2000' from x-axis, this should be:
2000x4 = 8000mg = 8g?
How can it be 8g when the measurement range is +-2g?
The reason I'm asking is because I'm trying to get the interrupt to work. It is working but not as expected. Either the interrupt never triggers, or it triggers priodically, even when the device is not moving.
2022-09-30 07:26 AM
sometimes the raw values are '255'.
My setup is Zephyr RTOS with an nrf5340 MCU interfacing the LIS2DH12 with SPI.
When I have this issue and reading the CTRL_REG1 and CTRL_REG4 the values are corrupted. CTRL_REG1 = 0x00 and CTRL_REG4 = 0xFF
But when it works those registers are correct configured. Don't know why those registers change, but probably the issue why the accelerometer values are incorrect.
2022-10-06 08:15 AM
Hi @BPapp.2 ,
Are your SPI or I2C lines, and Vdd and VddIO always stable during communication?
-Eleon
2022-10-07 01:18 AM
Got it to work now!
Think it might have been the magnetometer (LIS2MDL) connected to the same SPI-bus that was sending out some garbage. Saw that when CS is high the sensors are configured for I2C.
When I configured the magnetometer sensor in my device tree and enabled the LIS2MDL driver in Zephyr OS it is working fine.
But I have another question regarding the accelerometer LIS2DH12.
I'm trying to configure the interrupt, to trigger when e.g. the x-axis goes above a threshold value. Not sure what to put in the INT1_THS register?
and, in the output registers (OUT_X_L and OUT_X_H) what's the value/unit? is it in g, mg or m/s2?
Looked in the datasheet and looks like when the sensor is configured in Normal Mode with +-2g sensitivity, each digit is equal to 4mg?
So if I read out for example the raw value '2000' from x-axis, this should be:
2000x4 = 8000mg = 8g?
How can it be 8g when the measurement range is +-2g?
The reason I'm asking is because I'm trying to get the interrupt to work. It is working but not as expected. Either the interrupt never triggers, or it triggers priodically, even when the device is not moving.
2022-10-10 07:09 AM
Hi @BPapp.2 ,
thank you for having reported your solution!
I see you started another thread, I'll deal directly with that.
-Eleon