Auto-Wake/Sleep Using The MMA8451, 2, 3Q: Application Note
Auto-Wake/Sleep Using The MMA8451, 2, 3Q: Application Note
Auto-Wake/Sleep Using The MMA8451, 2, 3Q: Application Note
VDD
NC
NC
16 15 14
VDDIO 1 13 NC
BYP 2 12 GND
MMA845xQ
NC 3 16-Pin QFN 11 INT1
(Top View)
SCL 4 10 GND
GND 5 9 INT2
6 7 8
SA0
NC
SDA
Figure 1. MMA8451, 2, 3Q Consumer 3-axis Accelerometer 3 by 3 by 1 mm
2.1 Output Data, Sample Rates and Dynamic Ranges of all Three Products
2.1.1 MMA8451Q
1. 14-bit data
2g (4096 counts/g = 0.25 mg/LSB) 4g (2048 counts/g = 0.5 mg/LSB) 8g (1024 counts/g = 1 mg/LSB)
2. 8-bit data
2g (64 counts/g = 15.6 mg/LSB) 4g (32 counts/g = 31.25 mg/LSB) 8g (16 counts/g = 62.5 mg/LSB)
3. Embedded 32 sample FIFO (MMA8451Q)
2.1.2 MMA8452Q
1. 12-bit data
2g (1024 counts/g = 1 mg/LSB) 4g (512 counts/g = 2 mg/LSB) 8g (256 counts/g = 3.9 mg/LSB)
2. 8-bit data
2g (64 counts/g = 15.6 mg/LSB) 4g (32 counts/g = 31.25 mg/LSB) 8g (16 counts/g = 62.5 mg/LSB)
2.1.3 MMA8453Q Note: No HPF Data
1. 10-bit data
2g (256 counts/g = 3.9 mg/LSB) 4g (128 counts/g = 7.8 mg/LSB) 8g (64 counts/g = 15.6 mg/LSB)
2. 8-bit data
2g (64 counts/g = 15.6 mg/LSB) 4g (32 counts/g = 31.25 mg/LSB) 8g (16 counts/g = 62.5 mg/LSB)
AN4074
Sensors
2 Freescale Semiconductor, Inc.
3.0 Configuring the MMA8451, 2, 3Q into Auto-Wake/Sleep Mode
The MMA8451, 2, 3Q can be configured to transition between different sample rates (different current consumption) based on
different selected events. Enabling this feature can be accomplished by enabling the Sleep Mode and setting a timeout period.
Then the functions of interest must be set to trigger the device to wake. Both Wake and Sleep are considered “Active” Modes
because data and interrupts are available. The difference between the modes is that the sample rate in Sleep Mode is limited to
a maximum of 50 Hz. The advantage of using the Auto-Wake/Sleep is that the system can automatically transition to a higher
sample rate (higher current consumption) when needed but spends the majority of the time in the Sleep Mode (lower current)
when the device does not require higher sampling rates. This can all be triggered on selected events. The Low Noise bit (Register
0x2A bit 2) can be used as well with this feature. Be aware that using the Low Noise bit will limit the dynamic range to 4g,
regardless of the set range of the full scale value. The oversampling mode can also be changed from Active Sleep Mode to
Active Wake Mode. The Sleep Mode oversampling option is set in Register 0x2B using bit 3 and bit 4 SMODS0 and SMODS1.
The Active Wake Mode oversampling option is set in Register 0x2B using bit 0 and bit 1 MODS0 and MODS1. For example the
device can be configured to be in Low Power Mode when asleep at 1.56 Hz to be in the lowest current consumption configuration.
Then the device can be set for High Resolution Mode at 6.25 Hz when awake to be prepared to take higher resolution data for a
tilt application.
Figure 2 shows transition states from the Wake, Sleep and Standby modes.
Standby Wake
SYSMOD[1:0] = 00 SYSMOD[1:0] = 01
<DR>
er ts
gg up
ed
tri terr
In
If Time > ASLP_COUNT[7:0] and
Sleep no Interrupts triggered
SYSMOD[1:0] = 10
ASLP_RATE[1:0]
Table 2 shows the list of functions that will delay the device from returning to sleep and waking from sleep. Note that the
MMA8451Q is the only device that contains the FIFO. The FIFO can delay the device from going to sleep but it is not capable of
waking the device from sleep. The transient, portrait/landscape, tap, and motion/freefall functions can all delay the device from
sleep by servicing the interrupt before the timeout period. They can also wake the device from sleep. The Auto-Sleep interrupt
indicates when the device changes modes from Wake to Sleep or Sleep to Wake but the interrupt does not affect the state
change. Also the data ready interrupt does not affect the state change from the Wake to Sleep or Sleep to Wake state.
AN4074
Sensors
Freescale Semiconductor, Inc. 3
Table 2. Interrupt Sources and the effects on the state change from Wake to Sleep and Sleep to Wake Modes
FIFO_GATE Yes No
SRC_TRANS Yes Yes
SRC_LNDPRT Yes Yes
SRC_PULSE Yes Yes
SRC_FF_MT Yes Yes
SRC_ASLP No No
SRC_DRDY No No
Note that to configure the Auto-Wake/Sleep functionality, the selected embedded functions must be enabled (Register 0x2D)
and the same corresponding functions must be set to “Wake-from-Sleep” (Register 0x2C) if they are to be used to wake the de-
vice.
All enabled functions will still function in Sleep Mode at the sleep ODR. Only the functions that have been selected for “Wake-
from-Sleep” will wake the device. If nothing is selected to Wake-from-Sleep then the device will remain in Sleep Mode and will
never wake up.
This section reviews the different registers involved in configuring the device for auto-wake/sleep.
1. Register 0x2B bit 2 – SLPE Enable Sleep bit
2. Register 0x2B Set the Sleep Mode Oversampling Rate
3. Register 0x2A Sleep Sample Rate and Wake Sample Rate
4. Register 0x29 Timeout Counter
5. Register 0x2D Enable the Interrupts for the Selected Functions
6. Register 0x2E Route the Interrupts to INT1 or INT2
7. Register 0x2C Enable the Wake-from-Sleep Interrupts
3.2 Set the Sleep Mode and Wake Mode Oversampling Mode
There are four different oversampling modes described in Table 3 They are “Normal”, “Low Noise and Low Power”, “High Res-
olution” and “Low Power”. The oversampling mode changes the current consumption, resolution and also the debounce counter
timers in the part. The device can be configured to be in Low Power Mode while in Sleep and then to Normal Mode when awake
or any of the other fifteen combinations. This allows for further current savings in the Sleep Mode. The different bit settings are
shown in Table 3. The Wake oversampling modes configured from bit 0 and bit 1 in Register 0x2B. The Sleep oversampling
modes are configured from bit 3 and bit 4 in SMODS in Register 0x2B.
Table 3. Settings for Oversampling Modes
(S)MODS1 (S)MODS0 Power Mode
0 0 Normal
0 1 Low Noise and Low Power
1 0 High Resolution
1 1 Low Power
AN4074
Sensors
4 Freescale Semiconductor, Inc.
3.3 Configure the Sleep Sample Rate and Wake Sample Rate
It is important to note that when the device is in Sleep Mode, the system ODR is overwritten by the data rate set by the
ASLP_RATE field in the CTRL_REG1 Register (0x2A). The Sleep Sample Rate (ASLP_RATE[0:1]) and the Wake Mode Sample
Rate (DR[0:3]) are found in Table 5. The different bit settings for the Sleep Mode Sample Rate can be found in Table 6. The bit
settings for the Wake Mode Sample Rates are found in Table 7.
0 0 0 800.0 Hz 1.25 ms
0 0 1 400.0 Hz 2.5 ms
0 1 0 200.0 Hz 5 ms
0 1 1 100.0 Hz 10 ms
1 0 0 50.0 Hz 20 ms
1 0 1 12.5 Hz 80 ms
1 1 0 6.25 Hz 160 ms
1 1 1 1.56 Hz 640 ms
50 0 to 81s 20 ms 320 ms
AN4074
Sensors
Freescale Semiconductor, Inc. 5
3.5 Enable the Interrupts to be used in the System and Route to INT1 or INT2
The interrupt functions must be enabled in Register 0x2D per Table 10 for the event to trigger the Auto-Wake/Sleep. The func-
tions must also be configured with the appropriate thresholds and timing values to detect the events.
Table 10. Register 0x2D CTRL_REG4 Register (Read/Write) and Description
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
INT_EN_ASLP INT_EN_FIFO INT_EN_TRANS INT_EN_LNDPRT INT_EN_PULSE INT_EN_FF_MT — INT_EN_DRDY
The corresponding interrupt enable bit allows the function to route its event detection flag to the interrupt controller. The inter-
rupt controller routes the enabled interrupt to the INT1 or INT2 pin. By default all interrupts are routed to INT2 and the correspond-
ing configuration register bit value is 0. To route a functional block to INT1 instead of the default, set the corresponding
configuration register bit to 1. The configuration register bit settings are shown in Table 11.
Table 11. Register 0x2E CTRL_REG5 Register (Read/Write) and Description
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
INT_CFG_ASLP INT_CFG_FIFO INT_CFG_TRANS INT_CFG_LNDPRT INT_CFG_PULSE INT_CFG_FF_MT — INT_CFG_DRDY
Note: The FIFO is flushed whenever the system ODR changes in order to prevent mixing the FIFO data from different time
domains unless the FIFO_GATE (bit 7) is set. Also, the FIFO cannot wake the device from sleep but can prevent the device from
going to sleep. Details of the functionality of the FIFO is captured in Table 13.
Table 13. Behavior of FIFO under Wake/Sleep Conditions
FIFO INT Wake-from-Sleep Result
Enabled Enabled
FIFO will fall asleep when the sleep timer times out and no other interrupt wakes the system.
NO NO There is an AUTOMATIC flush and the FIFO starts refilling at the Sleep ODR from 0.
If another functional block causes the device to wake the FIFO will FLUSH itself again and start filling at
the Wake ODR.
With the interrupt enabled the FIFO can be read and flushed clearing the interrupt. The system is kept
from falling asleep by reading the status after the interrupt is set. The FIFO does not have to be flushed to
YES NO keep the device in Wake Mode- as long as the FIFO status is read continuously after the FIFO interrupt is
enabled. If the system falls asleep (and no new interrupts occur during the timeout period), the FIFO
AUTOMATICALLY flushes and starts refilling at the Sleep ODR from 0 and stores at the Wake ODR.
FIFO will fall asleep if no wake events occur within the timeout period.
NO YES Last data remains here in the FIFO until it is flushed.
Once the FIFO is flushed, it will start collecting the new data at the current ODR.
With interrupt enabled, the FIFO can be read and flushed (clearing the interrupt) . Note: Reading the FIFO
status will keep the system from falling asleep.
YES YES If the system does fall asleep (and no interrupts occur during the timeout period) then the FIFO will stop
collecting any data. The last data will be held in the FIFO.
Once the FIFO is flushed, it will start collecting the new data at the current ODR.
AN4074
Sensors
6 Freescale Semiconductor, Inc.
4.0 Example Configuration for the Auto-Wake/Sleep Function
The following are the steps to configure the Auto-Wake/Sleep function with the registers of importance in Table 14. In this ex-
ample, the data rate will be set to 100 Hz in Wake Mode and 6.25 Hz in Sleep Mode. The Oversampling Mode will be set to High
Resolution in the Wake Mode and Low Power Mode in Sleep Mode. The timeout period will be set to 20 seconds. The wake
triggers will be tap and motion. There may be other interrupts that are enabled in the system including orientation detection, but
these will not wake the device in this example.
Table 14. Registers used for Auto-Wake/Sleep Functionality
Reg Name Definition Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
System Mode
0B SYSMOD FGERR FGT_4 FGT_3 FGT_2 FGT_1 FGT_0 SYSMOD1 SYSMOD0
R
Interrupt Status
0C INT_SOURCE SRC_ASLP SRC_FIFO SRC_TRANS SRC_LNDPRT SRC_PULSE SRC_FF_MT — SRC_DRDY
R
Auto-Sleep Counter
29 ASLP_COUNT D7 D6 D5 D4 D3 D2 D1 D0
R/W
Control Reg1
2A CTRL_REG1 ASLP_RATE1 ASLP_RATE0 DR2 DR1 DR0 LNOISE F_READ ACTIVE
R/W
Control Reg2
2B CTRL_REG2 ST RST 0 SMODS1 SMODS0 SLPE MODS1 MODS0
R/W
Control Reg3
R/W
2C CTRL_REG3 FIFO_GATE WAKE_TRANS WAKE_LNDPRT WAKE_PULSE WAKE_FF_MT — IPOL PP_OD
(Wake Interrupts from
Sleep)
Control Reg4
2D CTRL_REG4 R/W INT_EN_ASLP INT_EN_FIFO INT_EN_TRANS INT_EN_LNDPRT INT_EN_PULSE INT_EN_FF_MT — INT_EN_DRDY
(Interrupt Enable Map)
Control Reg5
2E CTRL_REG5 R/W INT_CFG_ASLP INT_CFG_FIFO INT_CFG_TRANS INT_CFG_LNDPRT INT_CFG_PULSE INT_CFG_FF_MT — INT_CFG_DRDY
(Interrupt Configuration)
AN4074
Sensors
Freescale Semiconductor, Inc. 7
4.1 Example Procedure for Configuring the Auto-Wake/Sleep Function Conditions
• Dynamic Range = 2g
• Sleep Timeout period = 20 seconds
• Wake Triggers = Tap and Motion
• Wake Sample Rate = 100 Hz,
• Wake Oversampling Mode = High Resolution
• Sleep Sample Rate = 6.25 Hz
• Sleep Oversampling Mode = Low Power
AN4074
Sensors
8 Freescale Semiconductor, Inc.
Step 8: Set the Dynamic Range to 2g
Register 0x0E XYZ_DATA_CFG
XYZ_CFG_Data = IIC_RegRead(0x0E);
XYZ_CFG_Data & = 0xFC; //Clear the FS bits to 00 2g
IIC_RegWrite(0x0E, XYZ_CFG_Data);
Step 9: Write an Interrupt Service routine to monitor the Auto-Sleep Interrupt
Related Documentation
The MMA845xQ device features and operations are described in a variety of reference manuals, user guides, and application
notes. To find the most-current versions of these documents:
1. Go to the Freescale homepage at:
http://www.freescale.com/
2. In the Keyword search box at the top of the page, enter the device number MMA845xQ.
3. In the Refine Your Result pane on the left, click on the Documentation link.
AN4074
Sensors
Freescale Semiconductor, Inc. 9
How to Reach Us:
Home Page:
www.freescale.com
Web Support:
http://www.freescale.com/support
Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc.,
For Literature Requests Only:
Reg. U.S. Pat. & Tm. Off. The Energy Efficiency Solutions Logo and Xtrinsic are
Freescale Semiconductor Literature Distribution Center
1-800-441-2447 or +1-303-675-2140 trademarks of Freescale Semiconductor, Inc.
Fax: +1-303-675-2150 All other product or service names are the property of their respective owners.
[email protected] © 2012 Freescale Semiconductor, Inc. All rights reserved.
AN4074
Rev. 1
03/2012