Help setting up Auto-Wake/Sleep Using the MMA8452Q

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

Help setting up Auto-Wake/Sleep Using the MMA8452Q

Jump to solution
2,667 Views
flavioortolano
Contributor I

Hello there,

I am trying to configure the MMA8452Q to auto-sleep-wake but I am having no success at all.  The accelerometer works fine since I was able to configure it to output simple XYZ data.

I've downloaded the document AN4074 (Auto-Wake/Sleep Using the MMA8451, 2, 3Q) that seems to explain how to setup the wake/sleep fucntion, but again, it didn't work. I followed the pseudo-code on page 8 at the end of the document and I've noticed that although the example says it configures the device to sleep time-out period to 20 seconds, I could not identify in the pseudo-code the changes/updates related to the ASLP_COUNT Register (0x29) values.

Could someone give me some help on how to configure register 0x29? I have no idea (even after reading the documentation) how to set the bits D7-D0 for this register. What values should be written to this register when setting up the wake-sleep function?

At the stage of my prototype development, all I am trying to do right now is to get the accelerometer to sleep and be awaken after the device gets shaken - so any code/pseudo-code/explanation would be welcomed!!!

There are some code samples and libraries that I was able to find through Google, but not one single example nor code demonstrates how to setup the autp-wake-sleep. Any direction is much appreciated!

Thank you in advance.

Flavio

flavio@ortolanos.com

Labels (2)
Tags (2)
0 Kudos
Reply
1 Solution
1,849 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Flavio,

The pseudo-code on page 8 of the AN4074 is indeed incomplete. Attached you can find my example code I have written for the FRDM-KL25Z board and that demonstrates how to use the auto-wake/sleep function. The transient function is used to wake up the MMA8451Q and the time-out period is set to 5s. If you look at table 51 on page 36 of the MMA8452Q datasheet, you will see that the time step depends on the selected ODR. It is 640ms for 1.56Hz and 320ms for all other ODR values. In the attached example code the ODR is set to 100Hz and the required time-out period is 5s, so the value that needs to be written to the ASLP_COUNT register is 16 or 0x10 (=5s/320ms=~16).

I hope it helps. If you have any other questions, just let me know.


PS: If my answer solves your question, please mark it as "Correct" or “Helpful”. Thank you.

View solution in original post

0 Kudos
Reply
2 Replies
1,850 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Flavio,

The pseudo-code on page 8 of the AN4074 is indeed incomplete. Attached you can find my example code I have written for the FRDM-KL25Z board and that demonstrates how to use the auto-wake/sleep function. The transient function is used to wake up the MMA8451Q and the time-out period is set to 5s. If you look at table 51 on page 36 of the MMA8452Q datasheet, you will see that the time step depends on the selected ODR. It is 640ms for 1.56Hz and 320ms for all other ODR values. In the attached example code the ODR is set to 100Hz and the required time-out period is 5s, so the value that needs to be written to the ASLP_COUNT register is 16 or 0x10 (=5s/320ms=~16).

I hope it helps. If you have any other questions, just let me know.


PS: If my answer solves your question, please mark it as "Correct" or “Helpful”. Thank you.

0 Kudos
Reply
1,849 Views
flavioortolano
Contributor I

Tomas,

You are awesome!!!!

Your code helped me a lot and solved my issue!

You rock bud!

Thank you very much.

All the best

Flavio

0 Kudos
Reply