MMA8653FCR1 Configuring Interrupts

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

MMA8653FCR1 Configuring Interrupts

917 Views
curtisharrison
Contributor I


I've been trying off and on to set up an interrupt on the MMA8653FCR1 accelerometer.  I has seemed to be working from time to time, but then it would just not work.

I'm coding in the Energia environment and would appreciate some guidance as to what registers need to be set, and to what values.

Here's precisely what I need:

1. I need to run in low power mode.

2. When there is an abrupt movement detected (2g) I need the sensor to come alive and set an interrupt.

3. Please let me know if the interrupt is setting my pin to high or to low.

4. Is there anything I need to do when I get an interrupt so that future interrupts will fire?

5. I would like the interrupt to fire when I gently shake the board that has the MMA8653FCR1 on it.

Thanks for your assistance,

Curtis

0 Kudos
2 Replies

392 Views
david_diaz
NXP Employee
NXP Employee

Hello Curtis,

1. In order to set the Low Power Mode, you may refer to the MODS bits from the CTRL_REG2 System Control 2 register.

2. I would like to recommend the following Bare Metal Example project in order to know how to deal with the interrupts:

MMA8652FC - Bare metal example project

3. The interrupt polarity is set at the IPOL bit from the CTRL_REG3 Interrupt Control register.

4. The interrupt is cleared when reading the PL_STATUS register.

5. In case you need to generate an interrupt every time the accelerometer is shaken, I recommend to enable the Freefall/Motion Interrupt at the CTRL_REG4 register.

Please be aware that the Freefall/motion interrupt is routed to the INT2 by default. In order to change it, you may refer to the CTRL_REG5 register.

In order to get more information about the Freefall/Motion configuration and status registers, you may refer to the chapter 6.7 at the MMA8653FC datasheet​.

Please let me know if you need more detailed information about setting the Freefall registers.

I hope this information will be useful for you.

If I misunderstood your question, feel free to let me know.  I will be glad to help.

Have a great day.

David Diaz.

0 Kudos

392 Views
curtisharrison
Contributor I

I found the solution.  Here:  https://community.freescale.com/thread/378621#comments

For my code, I just needed to have the following methods:

void MMA8653::initialize()

{

     i2cSend(CTRL_REG1       ,0x00   ); //Standby Mode

     i2cSend(CTRL_REG2       ,0x07   ); //Autosleep enabled / Low Power

     i2cSend(CTRL_REG3       ,0x08   ); //Wake from Motion interrupt / Active Low / PushPull

     i2cSend(CTRL_REG4       ,0x04   ); //Enable Motion interrupt

     i2cSend(CTRL_REG5       ,0x04   ); //Interrupt on INT1

     i2cSend(FF_MT_CFG       ,0x71   ); //Event not latched/Motion/ Enable X/Y/Z detection on INT1

     i2cSend(FF_MT_THS       ,0x12   ); //Set threshold value to 1.134g

     i2cSend(FF_MT_COUNT     ,0x00   ); //Set number of debounce

     i2cSend(CTRL_REG1       ,0x21   ); //Set ODR to 200Hz & active mode

}

void MMA8653::clearInterrupt()

{

   char buffer[7];

   Wire.beginTransmission(adress_acc);

   Wire.write(FF_MT_SRC);

   Wire.endTransmission();

   Wire.requestFrom(adress_acc,7);

   Wire.readBytes(buffer, 7);

}

When an event happens, I just call clearInterrupt() and life is groofy.  Works like a charm

Thanks for all the help everybody !!!

0 Kudos