I am trying to detect free fall detection as per AN4070 application note, below are the register settings i have configured
MMA8452_CTRL1_REG = 0x20; //Set the device in 50 Hz ODR, Standby
MMA8452_FF_MT_CFG= 0xA0; //Configuration Register set for Freefall Detection enabling “AND” condition, OAE = 0, Enabling X, Y, Z and the Latch
MMA8452_FF_MT_THS = 0x03; //0.2g/0.063g = 3.17 counts //Round to 3 counts
MMA8452_FF_MT_COUNT = 0x06; //120 ms/20 ms (steps) = 6 counts
MMA8452_CTRL4_REG = 0x00; //Enable Motion/Freefall Interrupt Function in the System
MMA8452_CTRL5_REG= 0x00; //Route the Motion/Freefall Interrupt Function to INT2 hardware pin
IMMA8452_CTRL1_REG = MMA8452_CTRL1_REG | 0x01; //Put the device in Active Mode, 50 Hz
This configuration is followed by reading MMA8452_INT_SOURCE register, and the result is 0xFF;
and followed by reading MMA8452_FF_MT_SRC register, and the result of this register is also 0xFF;
Reading of register MMA8452_FF_MT_SRC should have cleared the freefall interuupt, and interrupt is always active and not clearing at all. Is there anything i am missing out? (I am not using hardware pin INT2 now, as there is hardware limitation)
Hi Justin,
First off, could you please double check that you are able to read the WHO_AM_I register (0x0D) and other previously initialized registers?
Then please try to change MMA8452_CTRL4_REG = 0x00 to MMA8452_CTRL4_REG = 0x04.
Best regards,
Tomas
Hi Tomas,
Thank you for your help.
I have corrected control Register 4 value to 0x04. Still not successful.
I tried to read WHO_AM_I register (0x0D) and the result is also 0xFF, It is supposed to be 0x2A,right?
I have verified the presence of 0x1C device in my I2C line and it is showing up correctly.
I also tried reading 6 bytes of data continuously from 0x01 to 0x06 , I am able to read the data and is acknowledged properly.
Here also the first data byte received is always 0xFF, remaining 5 data bytes are changing as per the acceleration too.
Meanwhile the same loop have another I2C based 1 byte memory write and read, and that works perfectly fine.
Any comments!
Hi Tomas,
MMA8452 is working fine, free fall also detecting.
I have changed my I2C communication mode for write operation (when write is used to set register for next read)
to Complete the transfer without a Stop.
Earlier i was using Full transfer with Start and Stop.
Thanks.
Justin
Hi Justin,
Glad to hear that, such troubles with I2C communication are quite common, that is why I always recommend to read the WHO_AM_I register at first as well as previously written registers. Using a logic analyzer or an oscilloscope helps a lot.
Best regards,
Tomas