MMA8452 freefall detection

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

MMA8452 freefall detection

2,819 Views
jusantony89
Contributor II

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) 

Labels (1)
4 Replies

2,647 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

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 

0 Kudos

2,647 Views
jusantony89
Contributor II

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!

0 Kudos

2,647 Views
jusantony89
Contributor II

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 

0 Kudos

2,647 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

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

%3CLINGO-SUB%20id%3D%22lingo-sub-854480%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMMA8452%20freefall%20detection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854480%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20trying%20to%20detect%20free%20fall%20detection%20as%20per%26nbsp%3BAN4070%20application%20note%2C%20below%26nbsp%3Bare%20the%20register%20settings%20i%20have%20configured%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EMMA8452_CTRL1_REG%20%3D%26nbsp%3B0x20%3B%26nbsp%3B%20%2F%2FSet%20the%20device%20in%2050%20Hz%20ODR%2C%20Standby%3C%2FP%3E%3CP%3EMMA8452_FF_MT_CFG%3D%26nbsp%3B0xA0%3B%20%2F%2FConfiguration%20Register%20set%20for%20Freefall%20Detection%20enabling%20%E2%80%9CAND%E2%80%9D%20condition%2C%20OAE%20%3D%200%2C%20%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BEnabling%20X%2C%20Y%2C%20Z%20and%20the%20Latch%3C%2FP%3E%3CP%3EMMA8452_FF_MT_THS%20%3D%200x03%3B%20%2F%2F0.2g%2F0.063g%20%3D%203.17%20counts%20%2F%2FRound%20to%203%20counts%3CBR%20%2F%3EMMA8452_FF_MT_COUNT%20%3D%200x06%3B%20%2F%2F120%20ms%2F20%20ms%20(steps)%20%3D%206%20counts%3C%2FP%3E%3CP%3EMMA8452_CTRL4_REG%26nbsp%3B%3D%200x00%3B%26nbsp%3B%20%2F%2FEnable%20Motion%2FFreefall%20Interrupt%20Function%20in%20the%20System%3CBR%20%2F%3EMMA8452_CTRL5_REG%3D%26nbsp%3B0x00%3B%26nbsp%3B%20%2F%2FRoute%20the%20Motion%2FFreefall%20Interrupt%20Function%20to%20INT2%20hardware%20pin%26nbsp%3B%3CBR%20%2F%3E%20IMMA8452_CTRL1_REG%26nbsp%3B%20%3D%20MMA8452_CTRL1_REG%20%7C%200x01%3B%26nbsp%3B%20%2F%2FPut%20the%20device%20in%20Active%20Mode%2C%2050%20Hz%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThis%20configuration%20is%20followed%20by%20reading%26nbsp%3BMMA8452_INT_SOURCE%20register%2C%20and%20the%20result%20is%200xFF%3B%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20followed%20by%20reading%20MMA8452_FF_MT_SRC%20register%3CSPAN%3E%2C%20and%20the%20result%20of%20this%20register%20is%20also%200xFF%3B%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EReading%20of%20register%20MMA8452_FF_MT_SRC%26nbsp%3Bshould%20have%20cleared%20the%20freefall%20interuupt%2C%20and%20interrupt%20is%20always%20active%20and%20not%20clearing%20at%20all.%20Is%20there%20anything%20i%20am%20missing%20out%3F%20(I%20am%20not%20using%20hardware%20pin%20INT2%20now%2C%20as%20there%20is%20hardware%20limitation)%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-854480%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAccelerometers%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854484%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA8452%20freefall%20detection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854484%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Justin%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EGlad%20to%20hear%20that%2C%20such%20troubles%20with%20I2C%20communication%20are%20quite%20common%2C%20that%20is%20why%20I%20always%20recommend%20to%20read%20the%26nbsp%3B%3CSPAN%20style%3D%22color%3A%20%23666666%3B%20background-color%3A%20%23ffffff%3B%22%3EWHO_AM_I%20register%20at%20first%20as%20well%20as%20previously%20written%20registers.%26nbsp%3BUsing%20a%20logic%20analyzer%20or%20an%20oscilloscope%26nbsp%3Bhelps%20a%20lot.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23666666%3B%20background-color%3A%20%23ffffff%3B%22%3EBest%20regards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23666666%3B%20background-color%3A%20%23ffffff%3B%22%3ETomas%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854483%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA8452%20freefall%20detection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854483%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3ETomas%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMMA8452%20is%20working%20fine%2C%20free%20fall%20also%20detecting.%26nbsp%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20have%20changed%20my%20I2C%20communication%20mode%20for%20write%20operation%20(when%20write%26nbsp%3Bis%20used%20to%20set%20register%20for%20next%20read)%3C%2FP%3E%3CP%3Eto%26nbsp%3B%3CSTRONG%3EComplete%20the%20transfer%20without%20a%20Stop.%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EEarlier%20i%20was%20using%20Full%20transfer%20with%20Start%20and%20Stop.%26nbsp%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThanks.%26nbsp%3B%3C%2FP%3E%3CP%3EJustin%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854482%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA8452%20freefall%20detection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854482%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3ETomas%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3EThank%20you%20for%20your%20help.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%2351626f%3B%20%22%3EI%20have%20corrected%20control%20Register%204%20value%20to%26nbsp%3B0x04.%20Still%20not%20successful.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%23666666%3B%20font-size%3A%2014px%3B%20%22%3EI%20tried%20to%20read%20WHO_AM_I%20register%20(0x0D)%26nbsp%3Band%20the%20result%20is%20also%200xFF%2C%20It%20is%20supposed%20to%20be%200x2A%2Cright%3F%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%23666666%3B%20font-size%3A%2014px%3B%20%22%3EI%20have%20verified%20the%20presence%20of%200x1C%20device%20in%20my%20I2C%20line%20and%20it%20is%20showing%20up%20correctly.%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%23666666%3B%20font-size%3A%2014px%3B%20%22%3EI%20also%20tried%20reading%206%20bytes%20of%20data%20continuously%26nbsp%3Bfrom%26nbsp%3B0x01%20to%200x06%20%2C%20I%20am%20able%20to%20read%20the%20data%20and%20is%20acknowledged%26nbsp%3Bproperly.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%23666666%3B%20font-size%3A%2014px%3B%20%22%3EHere%20also%20the%20first%20data%20byte%26nbsp%3Breceived%20is%20always%200xFF%2C%20remaining%205%20data%20bytes%20are%20changing%20as%20per%20the%26nbsp%3Bacceleration%20too.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%23666666%3B%20font-size%3A%2014px%3B%20%22%3EMeanwhile%20the%20same%20loop%20have%20another%20I2C%20based%201%20byte%20memory%20write%20and%20read%2C%20and%20that%20works%20perfectly%20fine.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%23666666%3B%20font-size%3A%2014px%3B%20%22%3EAny%20comments!%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-854481%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA8452%20freefall%20detection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-854481%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Justin%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EFirst%20off%2C%20could%20you%20please%20double%20check%20that%20you%20are%20able%20to%20read%20the%20WHO_AM_I%20register%20(0x0D)%20and%26nbsp%3Bother%20previously%20initialized%20registers%3F%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3EThen%20please%20try%20to%20change%20MMA8452_CTRL4_REG%26nbsp%3B%3D%200x00%20to%26nbsp%3B%3CSPAN%3EMMA8452_CTRL4_REG%26nbsp%3B%3D%200x04.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3E%3CSPAN%3EBest%20regards%2C%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%2351626f%3B%20background-color%3A%20%23ffffff%3B%22%3E%3CSPAN%3ETomas%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E