2017-11-17 01:11 PM
I am unable to generate an interrupt on INT2 pin. But I can generate an interrupt with the same configuration on INT1 pin. Seems like I am missing something obvious or the datasheet is missing something crucial!!
I am trying to detect a 180-degree flip from Z-axis. On a flat surface, Z-axis pointing upwards gives me approx +1g (decimal 65 with FS = 2). 180 flip will give me a negative value. Here is the configuration that worked on INT1 pin.
CTRL_REG2 = 0x42 // Reference filtering, Filter data for AOI function on interrupt 2
REFERENCE = 50 // Taking the z-axis value close to 15
CTRL_REG3 = 0x20 // IA2 interrupt on INT1
CTRL_REG5 = 0x08 // Latch for INT1
CTRL_REG6 = 0
INT2_THS = 100 // A 180-degree flip gives me around -112 with REFERENCE 50
INT2_DURATION = 50 // 500ms with ODR=100Hz
INT2_CFG = 0x20 // Interrupt enable for High on Z-axis
With above configuration, I can detect the interrupt on INT1 pin. For INT2 pin I changed,
CTRL_REG3 = 0
CTRL_REG5 = 0x02 // Latch for INT2
CTRL_REG6 = 0x20 // IA2 interrupt on INT2 pin
...and I don't receive any interrupt. I just redirected the pin. This should work. Unless I am missing something obvious. Any help will be much appreciated.
#accelerometer #mems #interrupt2017-11-20 02:02 AM
You configuration is correct and it is working, but I see one small issue which probably makes the troubles.
In the first case when the interrupt is directed to INT1 pin, you set
CTRL_REG5 = 0x08, this configuration set the Latch mode for the interrupt generator 1 not for the pin INT1. And because you are using interrupt generator 2 this settings is not used and the interrupt is not latched (returns back to 0 wen the boards is flipped back).
When you direct the interrupt to INT2 you set CTRL_REG5 = 0x02, this configuration set the Latch mode for interrupt generator 2. As you are using this interrupt generator, the INT2 pit remains high until you read INT2_SRC register.
I tried both case and the interrupt is triggered as you would expect but in second case I have to read the INT2_SRC register to clear the interrupt.
2017-11-21 10:37 AM
I see. That makes sense. Let me try your suggestion.