MMA7660 Auto-Wake / Auto Sleep mode

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

MMA7660 Auto-Wake / Auto Sleep mode

Jump to solution
3,733 Views
akircher
Contributor I

Hello,

I try to set up mma7660, that it runs in Auto Sleep with high sample rate and in Auto-Wake in low sample rate.

During the transition from Auto-Wake to Auto-Sleep I would like to fire an interrupt.

The interrupt trigger should be the Delta G condition.

Unfortunately I can not make it work. The initialisation looks like this:

void setup(){

   write(MODE,0x00);//0x00 = Stan dby Mode -- allows config to be written

    write(INTSU, INTSU_ASINT );// Interrupts for exiting Auto sleep

    write(PDET,PDET_XDA|PDET_YDA|PDET_ZDA);//Tap detection is disabled, no threshold

    write(PD,0x0);//No Tap Filtering

    write(SR,SR_AMSR_AM16 |SR_AWSR_AW1); // Sampling Rate aktive 16 hz ; sleep 16 hz

    write(SPCNT, 16);    //  counts for sleep counter register until sleep / wake occurs

    write(MODE,MODE_MODE| MODE_AWE  /*|MODE_ASE /*|MODE_IAH*/ );// MODE_MODE = Active Mode ; MODE_AWE = Auto Wake ;

           

    }

To understand MMA7660 is in sleep or active mode I use following code

uint8_t GetwakeState(){

    uint8_t   s =  read(SRST);

    if ( s & SRST_AMSRS )    return 1 ;  // AUTO SLEEP == active

    if ( s & SRST_AWSRS )  return 0 ;  // AUTO WAKE  == sleeping

    return -1;

}

Unfortunately between the transistions (sleep to wake or vice versa) I do not get always an interrupt,

If an interrupt occurs there are plenty in a row and not necessarly linked to the state change.

Output of log file

Ws: 0 = sleep ; 1 = active

Int : number of recived interrups

x,y,z = accelarations in x,y,z direction

Ws 0 Int 92 x = 2 y = -3 z = -13

Ws 0 Int 92 x = 2 y = -3 z = -13

Ws 0 Int 92 x = 4 y = -3 z = -21

Ws 0 Int 109 x = 4 y = -3 z = -21

Ws 0 Int 112 x = 4 y = -6 z = -25

Ws 2 Int 112 x = 3 y = -3 z = -21

Ws 2 Int 112 x = 3 y = -3 z = -21

Ws 0 Int 112 x = 2 y = -3 z = -17

Ws 0 Int 118 x = 2 y = -3 z = -17

Ws 0 Int 121 x = 4 y = -4 z = -27

Ws 0 Int 121 x = 4 y = -4 z = -27

Ws 1 Int 121 x = -3 y = 1 z = -18

Ws 1 Int 121 x = 1 y = 5 z = -23

Ws 1 Int 121 x = 1 y = 5 z = -23

Ws 1 Int 121 x = 1 y = 2 z = -22

Ws 1 Int 121 x = 1 y = 2 z = -22

Ws 2 Int 121 x = 3 y = 0 z = -17

Ws 2 Int 121 x = 3 y = 0 z = -17

Ws 1 Int 121 x = 1 y = 3 z = -19

Ws 1 Int 121 x = 1 y = 3 z = -19

Ws 0 Int 121 x = -2 y = -2 z = -24

Ws 1 Int 135 x = -7 y = -2 z = -20

Ws 1 Int 135 x = -7 y = -2 z = -20

Ws 2 Int 135 x = -1 y = 1 z = -23

If you can provide any sample code making use of the sleep / wake functionlity would be helpfull

Thanks a lot Andreas

Labels (1)
0 Kudos
1 Solution
2,134 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Andreas,

Just a quick note, the MMA7660FC is a pretty old device, not recommended for new designs. I strongly suggest using newer accelerometers such as the MMA845xQ, MMA865xFC or FXLS8471Q. There is also an app note AN4074 illustrating the use of the auto wake/sleep function on these devices.

Regards,

Tomas

View solution in original post

0 Kudos
2 Replies
2,134 Views
akircher
Contributor I

Thanks for this tip!

0 Kudos
2,135 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Andreas,

Just a quick note, the MMA7660FC is a pretty old device, not recommended for new designs. I strongly suggest using newer accelerometers such as the MMA845xQ, MMA865xFC or FXLS8471Q. There is also an app note AN4074 illustrating the use of the auto wake/sleep function on these devices.

Regards,

Tomas

0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-477325%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMMA7660%20Auto-Wake%20%2F%20Auto%20Sleep%20mode%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-477325%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20try%20to%20set%20up%20mma7660%2C%20that%20it%20runs%20in%20Auto%20Sleep%20with%20high%20sample%20rate%20and%20in%20Auto-Wake%20in%20low%20sample%20rate.%3C%2FP%3E%3CP%3EDuring%20the%20transition%20from%20Auto-Wake%20to%20Auto-Sleep%20I%20would%20like%20to%20fire%20an%20interrupt.%3C%2FP%3E%3CP%3EThe%20interrupt%20trigger%20should%20be%20the%20Delta%20G%20condition.%3C%2FP%3E%3CP%3EUnfortunately%20I%20can%20not%20make%20it%20work.%20The%20initialisation%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Evoid%20setup()%7B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%20write(MODE%2C0x00)%3B%2F%2F0x00%20%3D%20Stan%20dby%20Mode%20--%20allows%20config%20to%20be%20written%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20write(INTSU%2C%20INTSU_ASINT%20)%3B%2F%2F%20Interrupts%20for%20exiting%20Auto%20sleep%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20write(PDET%2CPDET_XDA%7CPDET_YDA%7CPDET_ZDA)%3B%2F%2FTap%20detection%20is%20disabled%2C%20no%20threshold%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20write(PD%2C0x0)%3B%2F%2FNo%20Tap%20Filtering%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20write(SR%2CSR_AMSR_AM16%20%7CSR_AWSR_AW1)%3B%20%2F%2F%20Sampling%20Rate%20aktive%2016%20hz%20%3B%20sleep%2016%20hz%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20write(SPCNT%2C%2016)%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%26nbsp%3B%20counts%20for%20sleep%20counter%20register%20until%20sleep%20%2F%20wake%20occurs%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20write(MODE%2CMODE_MODE%7C%20MODE_AWE%26nbsp%3B%20%2F*%7CMODE_ASE%20%2F*%7CMODE_IAH*%2F%20)%3B%2F%2F%20MODE_MODE%20%3D%20Active%20Mode%20%3B%20MODE_AWE%20%3D%20Auto%20Wake%20%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ETo%20understand%20MMA7660%20is%20in%20sleep%20or%20active%20mode%20I%20use%20following%20code%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Euint8_t%20GetwakeState()%7B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20uint8_t%26nbsp%3B%26nbsp%3B%20s%20%3D%26nbsp%3B%20read(SRST)%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20if%20(%20s%20%26amp%3B%20SRST_AMSRS%20)%26nbsp%3B%26nbsp%3B%26nbsp%3B%20return%201%20%3B%26nbsp%3B%20%2F%2F%20AUTO%20SLEEP%20%3D%3D%20active%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20if%20(%20s%20%26amp%3B%20SRST_AWSRS%20)%26nbsp%3B%20return%200%20%3B%26nbsp%3B%20%2F%2F%20AUTO%20WAKE%26nbsp%3B%20%3D%3D%20sleeping%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20return%20-1%3B%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3EUnfortunately%20between%20the%20transistions%20(sleep%20to%20wake%20or%20vice%20versa)%20I%20do%20not%20get%20always%20an%20interrupt%2C%3C%2FP%3E%3CP%3EIf%20an%20interrupt%20occurs%20there%20are%20plenty%20in%20a%20row%20and%20not%20necessarly%20linked%20to%20the%20state%20change.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EOutput%20of%20log%20file%3C%2FP%3E%3CP%3EWs%3A%200%20%3D%20sleep%20%3B%201%20%3D%20active%3C%2FP%3E%3CP%3EInt%20%3A%20number%20of%20recived%20interrups%3C%2FP%3E%3CP%3Ex%2Cy%2Cz%20%3D%20accelarations%20in%20x%2Cy%2Cz%20direction%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EWs%200%20Int%2092%20x%20%3D%202%20y%20%3D%20-3%20z%20%3D%20-13%3C%2FP%3E%3CP%3EWs%200%20Int%2092%20x%20%3D%202%20y%20%3D%20-3%20z%20%3D%20-13%3C%2FP%3E%3CP%3EWs%200%20Int%2092%20x%20%3D%204%20y%20%3D%20-3%20z%20%3D%20-21%3C%2FP%3E%3CP%3EWs%200%20Int%20109%20x%20%3D%204%20y%20%3D%20-3%20z%20%3D%20-21%3C%2FP%3E%3CP%3EWs%200%20Int%20112%20x%20%3D%204%20y%20%3D%20-6%20z%20%3D%20-25%3C%2FP%3E%3CP%3EWs%202%20Int%20112%20x%20%3D%203%20y%20%3D%20-3%20z%20%3D%20-21%3C%2FP%3E%3CP%3EWs%202%20Int%20112%20x%20%3D%203%20y%20%3D%20-3%20z%20%3D%20-21%3C%2FP%3E%3CP%3EWs%200%20Int%20112%20x%20%3D%202%20y%20%3D%20-3%20z%20%3D%20-17%3C%2FP%3E%3CP%3EWs%200%20Int%20118%20x%20%3D%202%20y%20%3D%20-3%20z%20%3D%20-17%3C%2FP%3E%3CP%3EWs%200%20Int%20121%20x%20%3D%204%20y%20%3D%20-4%20z%20%3D%20-27%3C%2FP%3E%3CP%3EWs%200%20Int%20121%20x%20%3D%204%20y%20%3D%20-4%20z%20%3D%20-27%3C%2FP%3E%3CP%3EWs%201%20Int%20121%20x%20%3D%20-3%20y%20%3D%201%20z%20%3D%20-18%3C%2FP%3E%3CP%3EWs%201%20Int%20121%20x%20%3D%201%20y%20%3D%205%20z%20%3D%20-23%3C%2FP%3E%3CP%3EWs%201%20Int%20121%20x%20%3D%201%20y%20%3D%205%20z%20%3D%20-23%3C%2FP%3E%3CP%3EWs%201%20Int%20121%20x%20%3D%201%20y%20%3D%202%20z%20%3D%20-22%3C%2FP%3E%3CP%3EWs%201%20Int%20121%20x%20%3D%201%20y%20%3D%202%20z%20%3D%20-22%3C%2FP%3E%3CP%3EWs%202%20Int%20121%20x%20%3D%203%20y%20%3D%200%20z%20%3D%20-17%3C%2FP%3E%3CP%3EWs%202%20Int%20121%20x%20%3D%203%20y%20%3D%200%20z%20%3D%20-17%3C%2FP%3E%3CP%3EWs%201%20Int%20121%20x%20%3D%201%20y%20%3D%203%20z%20%3D%20-19%3C%2FP%3E%3CP%3EWs%201%20Int%20121%20x%20%3D%201%20y%20%3D%203%20z%20%3D%20-19%3C%2FP%3E%3CP%3EWs%200%20Int%20121%20x%20%3D%20-2%20y%20%3D%20-2%20z%20%3D%20-24%3C%2FP%3E%3CP%3EWs%201%20Int%20135%20x%20%3D%20-7%20y%20%3D%20-2%20z%20%3D%20-20%3C%2FP%3E%3CP%3EWs%201%20Int%20135%20x%20%3D%20-7%20y%20%3D%20-2%20z%20%3D%20-20%3C%2FP%3E%3CP%3EWs%202%20Int%20135%20x%20%3D%20-1%20y%20%3D%201%20z%20%3D%20-23%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIf%20you%20can%20provide%20any%20sample%20code%20making%20use%20of%20the%20sleep%20%2F%20wake%20functionlity%20would%20be%20helpfull%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThanks%20a%20lot%20Andreas%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-477325%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-477327%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA7660%20Auto-Wake%20%2F%20Auto%20Sleep%20mode%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-477327%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThanks%20for%20this%20tip!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-477326%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA7660%20Auto-Wake%20%2F%20Auto%20Sleep%20mode%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-477326%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Andreas%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJust%20a%20quick%20note%2C%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsensors%2Faccelerometers%2F3-axis-accelerometers%2F1.5g-low-g-digital-accelerometer%3AMMA7660FC%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EMMA7660FC%3C%2FA%3E%20is%20a%20pretty%20old%20device%2C%20not%20recommended%20for%20new%20designs.%20I%20strongly%20suggest%20using%20newer%20accelerometers%20such%20as%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsensors%2Faccelerometers%2F3-axis-accelerometers%2F2g-4g-8g-low-g-14-bit-digital-accelerometer%3AMMA8451Q%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EMMA845xQ%3C%2FA%3E%2C%20%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsensors%2Faccelerometers%2F3-axis-accelerometers%2F2g-4g-8g-low-g-12-bit-digital-accelerometer%3AMMA8652FC%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EMMA865xFC%3C%2FA%3E%20or%20%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fsensors%2Faccelerometers%2F3-axis-accelerometers%2F2g-4g-8g-low-g-14-bit-digital-accelerometer%3AFXLS8471Q%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EFXLS8471Q%3C%2FA%3E.%20There%20is%20also%20an%20app%20note%20%3CA%20href%3D%22http%3A%2F%2Fcache.nxp.com%2Ffiles%2Fsensors%2Fdoc%2Fapp_note%2FAN4074.pdf%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EAN4074%3C%2FA%3E%20illustrating%20the%20use%20of%20the%20auto%20wake%2Fsleep%20function%20on%20these%20devices.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ETomas%3C%2FP%3E%3C%2FLINGO-BODY%3E