MMA8652 Clearing Interrupts

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MMA8652 Clearing Interrupts

2,038 Views
harsanys
Contributor II

I have been having great success so far using this MMA8652 part in my project.   My remaining issue is the following ... all works well and interrupts fire as expected.  However when I move my device in one or two orientations, and hold it still ... the Motion interrupt fires continuously, and I can't clear it using all the Read registers mentioned, only after I tilt the device back to a different orientation does it stop.  INT_SOURCE register will always read 0x04 when in the orientation that indicating that the Motion interrupt has triggered, and nothing can clear it till I rotate the device in a different orientation.

Background and config:

I am only using the Portrait/Landscape interrupt mode and Motion interrupt mode.   I am routing the PL Interrupt to INT1 and the motion interrupt to INT2.

Here are the commands in the order I send them, with the part in standby mode....

accel.write(MMA8652_CTRL_REG1, 0xF8);
accel.write(MMA8652_CTRL_REG2, 0x03);
accel.write(MMA8652_CTRL_REG3, 0x28);
accel.write(MMA8652_CTRL_REG4, 0x14);
accel.write(MMA8652_CTRL_REG5, 0x10);
accel.write(MMA8652_PL_CFG, 0x40);
accel.write(MMA8652_PL_COUNT, 0x1);
accel.write(MMA8652_FF_MT_CFG, 0x78);
accel.write(MMA8652_FF_MT_THS, 0x92);
accel.write(MMA8652_FF_MT_COUNT, 0x03);

Again all works with the PL interrupts as I can display returned position each time I get an interrupt, and the motion interrupt will trigger if I move the device fast as expected, but when I hold the device on it's left side, the motion interrupt continuously fires, turning it to the Right side all is well, or on it's belly, back all is well.

Thanks for any help or pointing out my mistake, as I am sure I am making one. :-)

Scott

Labels (1)
0 Kudos
5 Replies

1,437 Views
hoangtri
Contributor I

Hi Scott,

I have had an issue just like yours. After reading FF_MT_SRC register, interrupt still detect motion though i stop moving device but device still incline at an angle. Did you overcome this issue ?

Thanks for all advice and help.

Tri

0 Kudos

1,942 Views
reyes
NXP TechSupport
NXP TechSupport

Hi Scott,

 

INT_SOURCE register bits are cleared by reading the appropriate interrupt source register. For example, the SRC_FF_MT bit is cleared by reading the FF_MT_SRC register (0x16). SRC_FF_MT bit is not cleared by simply reading the INT_SOURCE register (0x0C).

 

Regards,

Jose

NXP Semiconductors

0 Kudos

1,942 Views
harsanys
Contributor II

Thanks Jose!  I am running off a ESP32 based board and configure the MMA8652 as I show above.  I set the interrupts to wake the ESP32 from sleep and then read the two registers you mention, then read INT_SOURCE.  If I run with either of the interrupts only (PL or Motion) then I can run for days without issue.  It is only when they are both on, and in that single orientation.   Right before I go to sleep on the ESP32 I have a while loop to read those two source registers and then the INT_SOURCE until I get a zero from INT_SOURCE or I try 5 times.  In this single orientation motion interrupt will never clear.  Any ideas?

Thanks

Scott

0 Kudos

1,942 Views
reyes
NXP TechSupport
NXP TechSupport

Hi Scott,

 

If the motion threshold has not been triggered, the interrupt should be clear after reading the FF_MT_SRC register (0x16) followed by the INT_ SOURCE register (0x0C), otherwise should be something wrong with your code.

Make sure the motion threshold has not been exceeded.

 

Regards,

Jose

NXP Semiconductors

0 Kudos

1,942 Views
harsanys
Contributor II

Thanks Jose! I am running off a ESP32 based board and configure the MMA8652 as I show above. I set the interrupts to wake the ESP32 and then read the two registers you mention, then read INT_SOURCE. If I run with either of the interrupts on (PL or Motion) then I can run for days without issue. It is only when they are both on, and in that single orientation. Right before I go to sleep I have a while loop to read those two source registers and then the INT_SOURCE until I get a zero from INT_SOURCE or I try 5 times. In this single orientation motion interrupt will never clear. Any ideas?

Thanks

Scott

Sent from Outlook Mobile<https://aka.ms/blhgte>

0 Kudos