cancel
Showing results for 
Search instead for 
Did you mean: 

LSM9DS1 - how to set up interrupts for the magnetometer? Datasheet description of the INT_THS_L and INT_THS_H registers unclear.

nebelgrau77
Associate II

The description of the threshold registers says: "The value is expressed in 15-bit unsigned. Even if the threshold is expressed in absolute value, the device detects both positive and negative thresholds.".

There is only one threshold to be set, despite the magnetometer having three axes.

I found a potentially matching explanation in an application note for the LSM303AGR magnetometer (AN4825):

"The interrupt threshold can be programmed using the [INT_THS_L]* and [INT_THS_H]* registers. When magnetic data exceeds the positive or the negative threshold, the interrupt signal is generated and the information about the type of interrupt is stored in the [INT_SRC_M]* register. In particular, when magnetic data exceeds the positive threshold, the [PTH_axis]* bit is set to '1', while if data exceeds the negative threshold, the [NTH_axis]* bit is set to '1'. If magnetic data lay between the positive and the negative thresholds, no interrupt signal is released."

*I replaced the register names with those of LSM9DS1

Is that also true for LSM9DS1? In other words:

  • there is only one threshold value that can be set
  • one or more axes can be selected in INT_CFG_M register as the axis where interrupt will be generated (but the threshold is always the same for all of them anyway)
  • whatever the threshold value is, if the measured value is below it then it's "negative", and if it's above then "positive"
  • the actual threshold value in mG is the threshold setting multiplied by the currently selected sensitivity, e.g. if the scale is set to +/- 4G, and the threshold value is decimal 1000, the actual value will be 0.14 * 1000

Could anyone confirm this? I haven't found a similar application note for LSM9DS1, and sometimes the datasheets are a bit vague, or they assume prior knowledge of a similar sensor maybe.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @nebelgrau77​ ,

The IG_XL and IG_G are general interrupt flags (the "OR" sum of the INT_GEN_SRC_XL and INT_GEN_SRC_G interrupts).

So yes, you are basically right, the two bits of the different registers refer to the same interrupts.

-Eleon

View solution in original post

7 REPLIES 7
Eleon BORLINI
ST Employee

Hi @nebelgrau77​ ,

the description of the two threshold registers for the magnetometer interrupt are correct.

The interrupt is generated in the positive direction when the magnetic field goes above threshold from a lower value, while the negative flag is risen when the magnetic field diminishes under the defined threshold. This threshold is the same for the 3 axis.

Moreover, as you pointed out, the threshold's LSB depends upon the FullScale, according to the formula FS / 2^15.

Hence, your assumptions are mostly correct.

If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster. 

-Eleon

nebelgrau77
Associate II

Great, thank you Eleon! I have an additional question regarding this sensor: there are two seemingly identical registers in the accelerometer/gyroscope part of the sensor, named STATUS_REG (17h and 27h). They seem to have identical fields, too. Are they simply duplicated for some convenience reason?

Hi @nebelgrau77​ ,

you are right, they are just duplicated, probably coming from the merging of the accelerometer and the gyroscope modules (sharing the bits in the final ASIC). On the other side, the magnetometer has its own STATUS_REG_M.

-Eleon

Great, thanks!

Hi Eleon,

I have one more question regarding the interrupts, this time XL/G. The STATUS_REG has two bits: IG_XL and IG_G, that go high when "one or more interrupt events have been generated" by accelerometer or gyroscope, respectively. At the same time the interrupt-specific registers INT_GEN_SRC_G and INT_GEN_SRC_XL both have IA_G and IA_XL bits, described exactly the same. Does it mean that an accelerometer interrupt event sets both IA_XL and IG_XL bits, etc.? What is the difference between those registers/bits?

Hi @nebelgrau77​ ,

The IG_XL and IG_G are general interrupt flags (the "OR" sum of the INT_GEN_SRC_XL and INT_GEN_SRC_G interrupts).

So yes, you are basically right, the two bits of the different registers refer to the same interrupts.

-Eleon

~Thank you!