MMA8452 Accelerometer

Contents

Description

The MMA8452 is a member of the MMA845x family which also includes the MMA8451 and the MMA8453.

MMA845x family of accelerator chips; top view, bottom view.
FIG 1 - MMA845x family of accelerator chips pictorial view: [Left] bottom view, [Right] top view

The MMA8452 was originally manufactured by Freescale Semiconductor. The Dutch public company, NXP Semiconductors, bought Freescale in a merger that was completed in December 2015.

The MMA8452 is officially a discontinued product but (in 2025) is still stocked by hobbyist retailers as leftover stock and available in several breakout board designs.

The MMA8452 is described in the datasheet (Page 1) as a smart, low-power, three-axis, capacitive, micromachined accelerometer with 12-bits resolution.

This accelerometer's typical applications include use in e-compass applications, static orientation detection, tumble and freefall detection in portable devices, virtual reality and 3D gaming, pedometer step counting, motion detection for portable product power saving, shock and vibration monitoring.

The MMA8452 measures acceleration with a capacitive type sensor.

The values in the following table have been sourced from the product datasheet.

Parameter DIS3DH
Package and size 16-pin QFN package, footprint 3mm x 3mm x 1mm.
Operating voltage range 1.95V to 3.6V
Supply current (typically)
[ODR/Oversampling]
[1.56Hz / Low] : 6µA
[800Hz / High] : 165µA
Standby: 1.8µA
Zero-g level offset accuracy ±20 mg
Measurement ranges ±2g, ±4g, ±8g
Default is ±2g.
Output resolution 12-bit
Sensitivity (typically) 1024 counts/g (±2g)
512 counts/g ((±4g))
256 counts/g (±8g)
Output data rate (ODR) 1.56Hz to 800Hz in 8 programmable steps
Serial interfaces I2C

Using the MMA8452's I2C Interface

The I2C interface is compliant with both normal mode (100kHz) and fast mode (400kHz). Single byte and multiple byte (burst mode) reading and writing is supported.

I2C addresses

There are two I2C addresses available. They are factory set and depend on whether the SOA pin is held at a Low or High logic level.

  • SAO = 0 : 0x1C
  • SAO = 1 : 0x1D

Reading MMA8452 registers

There is a very important point to made with respect to reading MMA8452 registers through the I2C interface. This involves how the stop condition is used.

  1. Master issues a start condition.
  2. Master writes the 7-bit slave address and adding LSB = 0 for write.
  3. Slave acknowledges.
  4. Master writes the slaves's register address.
  5. Slave acknowledges.
  6. Master issues a repeat start condition.
  7. Master writes the 7-bit slave address and adding LSB = 1 for read.
  8. Slave acknowledges and sends bytes of data. The Master acknowledges each byte received. When the required number of bytes have been received the Master does not acknowledge but instead issues a stop condition to cease transmission.

The point to note here is that if the Master issues a stop condition at the end of Step 4, the Slave will reset the register pointer and the desired register will not be read in the subsequent steps.

This is not usually the case with the I2C interfaces of many other sensors.

Acceleration Sampling Options

This accelerometer has a useful set of sampling options that the user may choose to configure.

Operating modes

  • Standby

    Low current consumption mode (typically <2 µA) where data conversions are stopped but the I2C interface is still available. This is the default mode after the power-up sequence has completed.
  • Active Mode

    This is the normal acceleration measurement mode of the sensor. There are two states to the active mode: active/wake  and active/sleep.
    • Active/sleep

      The sensor is in lower power state where conversions are being performed at a lower data rate output. This state can immediately transition to the active/wake state on being triggered by any one of four separate interrupts; tap detection, orientation detection, motion/freefall and transient detection.
    • Active/wake

      This state allows acceleration sampling at higher data rates with subsequent increased power use. Oversampling and low noise configuration can be used for better precision and accuracy.

Additional User Selections

  • Acceleration ranges

    Ranges available: ±2g, ±4g, ±8g. Default is ±2g.
  • Output data rate (ODR)

    The output data rate is user selectable from 1.56Hz to 800Hz in eight discrete steps; 1.56, 6.25, 12.5, 50, 100 , 200, 400, 800 (default).
  • Oversampling

    Oversampling involves extra samples from the sensor being taken then the average is sent to the output. The higher the oversampling, the higher the precision of the acceleration read from the I2C interface. However increased oversampling comes at the cost of higher power consumption.

    There are four oversampling modes; Normal, Low Noise Low Power, High Resolution, Low Power. The actual oversampling ratio depends on the OS mode selected and the ODR.

    The largest amount of oversampling occurs in OS mode = High Resolution at an ODR = 1.56Hz. With these settings the oversampling ratio is a huge 1024.
  • Low Noise

    Separate and in addition to oversampling, the MMA8452 has a low noise specific setting that increases precision when active.

Measuring Acceleration

The MMA8452 measures both static and dynamic acceleration. Acceleration is reported in units of g where 1g = 9.81 m/s2 i.e. the acceleration due Earth's gravity.

The raw acceleration value for each axis is read from two 8-bit registers. The two bytes are combined to a single binary 12-bit representation. This is converted from its Two's Complementary format to a signed integer.

This is then scaled by simple division with the divisor being the sensitivity (counts/g). The sensitivity depends upon the measurement range. The float type result is the acceleration value in units of g.

There is a data ready interrupt that is asserted when fresh 3-axis acceleration data becomes available. There are also individual data ready interrupts available for each of the three axis; X, Y and Z.

FIFO Queue

The FIFO is a queue mechanism (First In - First Out) that when activated automatically begins storing datasets of raw 3-axis acceleration values.

The MMA8451 and MMA8453 have a FIFO capable of collecting 32 acceleration samples for each of the three axis before overflowing. The MMA8452 does not have this FIFO capability.

Sensor Generated Interrupts

The MMA8452 has a flexible interrupt architecture that can be configured with thresholds and timing values to assist in detecting a variety of scenarios.

All of the interrupts described below, once programmed, can be mapped to either of the two hardware pins INT1 and INT2.

Freefall detection

This involves monitoring al three axis for the condition where the magnitude of all acceleration samples are below a threshold for a configurable amount of time.

Motion detection

This is very flexible. When the accelerations exceed a set of thresholds for a given amount of time the motion interrupt is asserted.

Depending upon the thresholds and timing values different types of motions from a fast moving shake, a slow moving tilt or even a spinning motion can all be individually discerned.

Tap detection

The MMA8452 has embedded logic to detect single taps, double taps and directional taps. The user configurable options including high-pass and low-pass filtering are quite comprehensive.

Orientation detection

An algorithm allows for the detection of all six possible orientations; face-up, face-down, portrait, portrait flipped, landscape left, and landscape right.

This algorithm is not near as sophisticated as that employed by the MMA8451. The transition between orientations has strictly defined angle points that are not user configurable.

MMA8452 Chip ID

During the manufacturing process each chip has an MMA8452 identifier written to non-volatile memory.

The user is able to read this value from the WHO_AM_I   register. A genuine MMA8452 will return the value of 0x2A.

MMA8452 MicroPython Driver

An MMA8452 MicroPython driver specifically written for the BBC micro:bit has been developed as part of this series on MicroPython for the micro:bit. The driver webpage also provides a detailed description of the driver's methods and properties with sample code.

The driver implements the base functionality:

  • Setting power mode, ODR, measurement range (FS), oversampling and low noise configuration.
  • Acceleration readings and data ready status.
  • Measuring angles in the X and Y axis.
  • Chip ID/identification.

Activity/Orientation interrupts are beyond the scope of this driver.