cancel
Showing results for 
Search instead for 
Did you mean: 

IIS2MDC Threshold setting and actual values ambiguity.

pLanka
Associate II

Hi,

I am working on a project to read the magnetic field with the IIS2MDCTR chip. Actually, I am replacing a read switch with this accelerometer. I use the IIS2MDCSensor Arduino library. After testing with the magnet, I set the threshold to 10000. Enabled the interrupt on all axes in pulsed mode and routed it to the INT pin to get my microcontroller. (STM32U385VGT6) interrupted. When I close the magnet from the z-direction, I get the interrupt. But when I bring it closure from an angle, it does not change the pin status. I tried printing the ODR register values. I saw one, two, or three register values go beyond the 10000 threshold. But I do not get the interrupt. But when I move from the z direction, I am getting the interrupt even when only one axis exceeds the threshold. 

Can somebody explain the situation and advise me to understand this behaviour? 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi, Federica

I tested and found the issue. As I mentioned earlier, the issue was the scaling. I need to correct the threshold value with the scale before loading into the threshold registers. Now everything works fine. 

 

Thanks

 

 

 

View solution in original post

4 REPLIES 4
Federica Bossi
ST Employee

Hi @pLanka ,

Can you double-check that interrupts are enabled on all three axes in the sensor registers?

Thanks

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,

Thanks for your quick response. 

Yes, I have enabled interrupts on all three axes. I think the issue is with scaling. The values read from the getAxis() function in the library scale the raw register readings and put them as int32 numbers in the given array. But I just set the threshold registers to 10000. I, too, need to scale my threshold with the same scale before loading into the register. I then should compare the printed values with the scaled threshold. I will do that test and update the blog tomorrow. 

 

 

Hi, Federica

I tested and found the issue. As I mentioned earlier, the issue was the scaling. I need to correct the threshold value with the scale before loading into the threshold registers. Now everything works fine. 

 

Thanks

 

 

 

Hi @pLanka ,

I'm glad to hear that you've solved your issue.

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.