<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MMA8452Q accelerometer in Sensors</title>
    <link>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396202#M1508</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bryan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="CS"&gt;Your code seems to be absolutely correct. To be sure your I2C communication is running properly, could you please try to read the WHO_AM_I register (0x0D) and all output data registers &lt;/SPAN&gt;(0x01 – 0x06) while the device is perfectly level and not moving? The MMA8452Q ID is 0x2A, the X/Y axes should read ~0g and the Z axis should read ~1g, which is +1024 at ±2g range. If you are not able to read correct values from these registers, then please post here screenshots illustrating both I2C write and read transactions (as shown in my &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-101192"&gt;example code&lt;/A&gt;) as well as your complete schematic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 8.5pt; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;PS: If my answer helps to solve your question, please mark it as "Correct". Thank you.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 May 2015 09:17:25 GMT</pubDate>
    <dc:creator>TomasVaverka</dc:creator>
    <dc:date>2015-05-27T09:17:25Z</dc:date>
    <item>
      <title>MMA8452Q accelerometer</title>
      <link>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396201#M1507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;I am using the MMA8452Q Breakout Board from Spark Fun (&lt;A href="https://www.sparkfun.com/products/12756" title="https://www.sparkfun.com/products/12756" target="_blank"&gt;SparkFun Triple Axis Accelerometer Breakout - MMA8452Q - SEN-12756 - SparkFun Electronics)&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;I have followed the steps exactly on page 11 of "Motion and Freefall Detection Using the MMA8451, 2, 3Q" (&lt;/SPAN&gt;&lt;A href="http://cache.freescale.com/files/sensors/doc/app_note/AN4070.pdf" style="color: #1155cc; font-family: arial, sans-serif; font-size: 12.8000001907349px;" target="_blank"&gt;http://cache.freescale.com/files/sensors/doc/app_note/AN4070.pdf&lt;/A&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;), but my MMA8452Q accelerometer continues to indicate motion detection even when it is completely still.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;My C code is:&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;DIV&gt;#define MMA8452Q_ADDR&amp;nbsp; 0x3A&amp;nbsp; //0b 0011 1010 (accelerometer device I2C address (0x1D) plus 0 LSb for R/W bit)&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define INT_SOURCE 0x0C&amp;nbsp; // system interrupt status register &lt;/P&gt;&lt;P&gt;#define FF_MT_CFG&amp;nbsp; 0x15&amp;nbsp; // motion configuration register address&lt;/P&gt;&lt;P&gt;#define FF_MT_SRC 0x16&amp;nbsp;&amp;nbsp; // motion source register&lt;/P&gt;&lt;P&gt;#define FF_MT_THS&amp;nbsp; 0x17&amp;nbsp; // motion threshold register address&lt;/P&gt;&lt;P&gt;#define FF_MT_COUNT 0x18 // motion debounce counter register address&lt;/P&gt;&lt;P&gt;#define CTRL_REG1&amp;nbsp; 0x2A&amp;nbsp; // system control 1 register address&lt;/P&gt;&lt;P&gt;#define CTRL_REG4&amp;nbsp; 0x2D&amp;nbsp; // system control 4 register address&lt;/P&gt;&lt;P&gt;#define CTRL_REG5&amp;nbsp; 0x2E&amp;nbsp; // system control 5 register address&lt;/P&gt;&lt;/DIV&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;DIV&gt;volatile int FFMT_IntSourceReg_data; // holds data from FF_MT_SRC register in accelerometer MMA8452Q&lt;P&gt;&lt;/P&gt;&lt;P&gt;volatile int IntSourceSystemRegData; // holds data from INT_SOURCE register in accelerometer MMA8452Q&lt;/P&gt;&lt;/DIV&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;int main (void)&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;{&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp; consecutive = 0;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; n = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; configI2C1(400); // configure I2C baud rate for 400 KHz &lt;/P&gt;&lt;P&gt;&amp;nbsp; write2I2C1(MMA8452Q_ADDR, CTRL_REG1, 0x18); // ODR=100Hz, LNOISE=1, F_READ=0, ACTIVE=0&lt;/P&gt;&lt;P&gt;&amp;nbsp; write2I2C1(MMA8452Q_ADDR, FF_MT_CFG, 0xD8); // ELE=1, OAE=1, ZEFE=0, YEFE=1, XEFE=1&lt;/P&gt;&lt;P&gt;&amp;nbsp; write2I2C1(MMA8452Q_ADDR, FF_MT_THS, 0x30); // 3g/0.063g=47.6 (round up to 48), Threshold &amp;gt; 3g&lt;/P&gt;&lt;P&gt;&amp;nbsp; write2I2C1(MMA8452Q_ADDR, FF_MT_COUNT, 0x0A); // set debounce counter to eliminate false readings for 100Hz sample rate with requirement of 100 ms timer&lt;/P&gt;&lt;P&gt;&amp;nbsp; write2I2C1(MMA8452Q_ADDR, CTRL_REG4, 0x04); // disable auto SLEEP/WAKE interrupt, enable FF_MT interrupt&lt;/P&gt;&lt;P&gt;&amp;nbsp; write2I2C1(MMA8452Q_ADDR, CTRL_REG5, 0x04); // FF_MT interrupt output signal assigned to INT1 pin of MMA8452Q&lt;/P&gt;&lt;P&gt;&amp;nbsp; write2I2C1(MMA8452Q_ADDR, CTRL_REG1, 0x19); // put MMA8452Q in ACTIVE mode &lt;/P&gt;&lt;/DIV&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;DIV&gt;if (TimerCount % 1000 == 0)&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; write1I2C1(MMA8452Q_ADDR, INT_SOURCE);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; read1I2C1(MMA8452Q_ADDR, &amp;amp;IntSourceSystemRegData);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((IntSourceSystemRegData &amp;amp; 0x04)==0x04)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n++;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; consecutive = -3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; readRTCC(); // read real time clock and calendar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("MOTION DETECTION n=%d consecutive=%3d %02d:%02d:%02d\n",n,consecutive,HOUR,MIN,SEC);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; write1I2C1(MMA8452Q_ADDR, FF_MT_SRC);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read1I2C1(MMA8452Q_ADDR, &amp;amp;FFMT_IntSourceReg_data); // read the FF_MT_SRC register to clear the interrupt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/DIV&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;} // end of main&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;My "TimerCount" variable just assures that the INT_SOURCE register will be read and checked for an indication of motion every second. &lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;I have actually run the above program with 2 different MMA8452Q accelerometers, and I get the same results with both accelerometers: Every second the accelerometer claims that motion has occurred (i.e., "MOTION DETECTION" is printed) even though the accelerometer is perfectly still. I am only trying to detect when motion occurs in a sleeping subject; I am not interested in the specifics of the motion; however, I also ran a program that looked at the values of the OUT_X_MSB, OUT_Y_MSB, and OUT_Z_MSB registers, and they displayed a constant value of 255 even when no motion was occurring.&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;Can someone please tell me what I am doing wrong?&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;Thanks,&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;Bryan Bennett&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2026 21:57:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396201#M1507</guid>
      <dc:creator>bryanbennett</dc:creator>
      <dc:date>2026-02-03T21:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: MMA8452Q accelerometer</title>
      <link>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396202#M1508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bryan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="CS"&gt;Your code seems to be absolutely correct. To be sure your I2C communication is running properly, could you please try to read the WHO_AM_I register (0x0D) and all output data registers &lt;/SPAN&gt;(0x01 – 0x06) while the device is perfectly level and not moving? The MMA8452Q ID is 0x2A, the X/Y axes should read ~0g and the Z axis should read ~1g, which is +1024 at ±2g range. If you are not able to read correct values from these registers, then please post here screenshots illustrating both I2C write and read transactions (as shown in my &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-101192"&gt;example code&lt;/A&gt;) as well as your complete schematic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 8.5pt; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;PS: If my answer helps to solve your question, please mark it as "Correct". Thank you.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 09:17:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396202#M1508</guid>
      <dc:creator>TomasVaverka</dc:creator>
      <dc:date>2015-05-27T09:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: MMA8452Q accelerometer</title>
      <link>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396203#M1509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the quick response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the complete C code that I am running on my Microchip&lt;/P&gt;&lt;P&gt;PIC24HJ64GP502 microcontroller with the MMA8452Q accelerometer (being held&lt;/P&gt;&lt;P&gt;perfectly level and not moving):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "pic24_all.h"&lt;/P&gt;&lt;P&gt;#include "stdio.h"&lt;/P&gt;&lt;P&gt;#include "main.h"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define PERIOD  40000&lt;/P&gt;&lt;P&gt;#define MMA8452Q_ADDR  0x3A  //0b 0011 1010 (accelerometer device I2C&lt;/P&gt;&lt;P&gt;address (0x1D) plus 0 LSb for R/W bit)&lt;/P&gt;&lt;P&gt;#define OUT_X_MSB 0x01   // X-axis output data&lt;/P&gt;&lt;P&gt;#define OUT_X_LSB  0x02   // X-axis output data&lt;/P&gt;&lt;P&gt;#define OUT_Y_MSB 0x03   // Y-axis output data&lt;/P&gt;&lt;P&gt;#define OUT_Y_LSB  0x04   // Y-axis output data&lt;/P&gt;&lt;P&gt;#define OUT_Z_MSB 0x05   // Z-axis output data&lt;/P&gt;&lt;P&gt;#define OUT_Z_LSB  0x06   // Z-axis output data&lt;/P&gt;&lt;P&gt;#define INT_SOURCE 0x0C  // system interrupt status register&lt;/P&gt;&lt;P&gt;#define WHO_AM_I 0x0D     // MMA8452Q ID register&lt;/P&gt;&lt;P&gt;#define FF_MT_CFG  0x15  // motion configuration register address&lt;/P&gt;&lt;P&gt;#define FF_MT_SRC 0x16   // motion source register&lt;/P&gt;&lt;P&gt;#define FF_MT_THS  0x17  // motion threshold register address&lt;/P&gt;&lt;P&gt;#define FF_MT_COUNT 0x18 // motion debounce counter register address&lt;/P&gt;&lt;P&gt;#define CTRL_REG1  0x2A  // system control 1 register address&lt;/P&gt;&lt;P&gt;#define CTRL_REG2  0x2B  // system control 2 register address&lt;/P&gt;&lt;P&gt;#define CTRL_REG3  0x2C  // system control 3 register address&lt;/P&gt;&lt;P&gt;#define CTRL_REG4  0x2D  // system control 4 register address&lt;/P&gt;&lt;P&gt;#define CTRL_REG5  0x2E  // system control 5 register address&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;volatile int FFMT_IntSourceReg_data; // holds data from FF_MT_SRC register&lt;/P&gt;&lt;P&gt;in accelerometer MMA8452Q&lt;/P&gt;&lt;P&gt;volatile int IntSourceSystemRegData; // holds data from INT_SOURCE register&lt;/P&gt;&lt;P&gt;in accelerometer MMA8452Q&lt;/P&gt;&lt;P&gt;volatile int XrawData1, XrawData2, YrawData3, YrawData4, ZrawData5,&lt;/P&gt;&lt;P&gt;ZrawData6;&lt;/P&gt;&lt;P&gt;volatile int TimerCount;&lt;/P&gt;&lt;P&gt;volatile int Xout_12_bit, Yout_12_bit, Zout_12_bit;&lt;/P&gt;&lt;P&gt;int n, Accel_ID,year, month_date, wday_hour, min_sec, HOUR, HRTEN, HRONE,&lt;/P&gt;&lt;P&gt;MIN, MINTEN, MINONE, SEC, SECTEN, SECONE,MTH, MTHTEN, MTHONE, DAY, DAYTEN,&lt;/P&gt;&lt;P&gt;DAYONE, YR, YRTEN, YRONE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void setRTCC(void)  // set real time clock &amp;amp; calendar&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; NVMKEY = 0x55;   // unlock write to RTCC&lt;/P&gt;&lt;P&gt; NVMKEY = 0xAA;&lt;/P&gt;&lt;P&gt; RCFGCALbits.RTCWREN = 1; //enable write to RTCC&lt;/P&gt;&lt;P&gt; RCFGCALbits.RTCEN = 0; // disable RTCC&lt;/P&gt;&lt;P&gt; RCFGCALbits.RTCOE = 1; // enable RTCC output to pin #25&lt;/P&gt;&lt;P&gt; PADCFG1bits.RTSECSEL = 1; // seconds clock is selected for RTCC pin #25&lt;/P&gt;&lt;P&gt; RCFGCALbits.RTCPTR = 3; // set RTCC pointer to start&lt;/P&gt;&lt;P&gt; RTCVAL = 0x0015;  // set year in BCD&lt;/P&gt;&lt;P&gt; RTCVAL = 0x0528;  // set month_date in BCD&lt;/P&gt;&lt;P&gt; RTCVAL = 0x0401;  // set wday_hour in BCD&lt;/P&gt;&lt;P&gt; RTCVAL = 0x1100;  // set min_sec in BCD&lt;/P&gt;&lt;P&gt; RCFGCALbits.RTCEN = 1; // enable RTCC&lt;/P&gt;&lt;P&gt; RCFGCALbits.RTCWREN = 0; // disable write to RTCC&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void readRTCC(void)  // read real time clock &amp;amp; calendar&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; RCFGCALbits.RTCPTR = 3; // set RTCC pointer to start&lt;/P&gt;&lt;P&gt; year = RTCVAL;&lt;/P&gt;&lt;P&gt; month_date = RTCVAL;&lt;/P&gt;&lt;P&gt; wday_hour = RTCVAL;&lt;/P&gt;&lt;P&gt; min_sec = RTCVAL;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; YRTEN = ((year &amp;amp; 0xF0) &amp;gt;&amp;gt; 4) * 10;&lt;/P&gt;&lt;P&gt; YRONE = year &amp;amp; 0x0F;&lt;/P&gt;&lt;P&gt; YR = YRTEN + YRONE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; MTH = (month_date &amp;amp; 0xFF00) &amp;gt;&amp;gt; 8;&lt;/P&gt;&lt;P&gt; MTHTEN = ((MTH &amp;amp; 0xF0) &amp;gt;&amp;gt; 4) * 10;&lt;/P&gt;&lt;P&gt; MTHONE = MTH &amp;amp; 0x0F;&lt;/P&gt;&lt;P&gt; MTH = MTHTEN + MTHONE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; DAY = month_date &amp;amp; 0x00FF;&lt;/P&gt;&lt;P&gt; DAYTEN = ((DAY &amp;amp; 0xF0) &amp;gt;&amp;gt; 4) * 10;&lt;/P&gt;&lt;P&gt; DAYONE = DAY &amp;amp; 0x0F;&lt;/P&gt;&lt;P&gt; DAY = DAYTEN + DAYONE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; HOUR = wday_hour &amp;amp; 0x00FF;&lt;/P&gt;&lt;P&gt; HRTEN = ((HOUR &amp;amp; 0xF0) &amp;gt;&amp;gt; 4) * 10;&lt;/P&gt;&lt;P&gt; HRONE = HOUR &amp;amp; 0x0F;&lt;/P&gt;&lt;P&gt; HOUR = HRTEN + HRONE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; MIN = (min_sec &amp;amp; 0xFF00) &amp;gt;&amp;gt; 8;&lt;/P&gt;&lt;P&gt; MINTEN = ((MIN &amp;amp; 0xF0) &amp;gt;&amp;gt; 4) * 10;&lt;/P&gt;&lt;P&gt; MINONE = MIN &amp;amp; 0x0F;&lt;/P&gt;&lt;P&gt; MIN = MINTEN + MINONE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SEC = min_sec &amp;amp; 0x00FF;&lt;/P&gt;&lt;P&gt; SECTEN = ((SEC &amp;amp; 0xF0) &amp;gt;&amp;gt; 4) * 10;&lt;/P&gt;&lt;P&gt; SECONE = SEC &amp;amp; 0x0F;&lt;/P&gt;&lt;P&gt; SEC = SECTEN + SECONE;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void configTimer1( void )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;//This code should be written to do the interrupt rate at 1 msec (1 kHz&lt;/P&gt;&lt;P&gt;rate).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T1CON = 0; /* ensure Timer 1 is in reset state */&lt;/P&gt;&lt;P&gt;  IFS0bits.T1IF = 0; /* reset Timer 1 interrupt flag */&lt;/P&gt;&lt;P&gt;IPC0bits.T1IP = 4; /* set Timer1 interrupt priority level to 4 */&lt;/P&gt;&lt;P&gt;  IEC0bits.T1IE = 1; /* enable Timer 1 interrupt */&lt;/P&gt;&lt;P&gt;PR1 = PERIOD; /* set Timer 1 period register */&lt;/P&gt;&lt;P&gt;T1CONbits.TCKPS1 = 0; /* select Timer1 Input Clock Prescale */&lt;/P&gt;&lt;P&gt;T1CONbits.TCS = 0;  /* select internal timer clock */&lt;/P&gt;&lt;P&gt;T1CONbits.TON = 1;  /* enable Timer 1 and start the count */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void _ISR _T1Interrupt (void) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TimerCount++;    // increment TimerCount each millisecond&lt;/P&gt;&lt;P&gt;_T1IF = 0;          // clear T1 interrupt flag&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main (void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; __builtin_write_OSCCONL(OSCCON | 0x02); // unlock OSCCON register and set&lt;/P&gt;&lt;P&gt;LPOSCEN bit (enable secondary oscillator)&lt;/P&gt;&lt;P&gt;  setRTCC();&lt;/P&gt;&lt;P&gt;  configTimer1();&lt;/P&gt;&lt;P&gt;  configBasic(HELLO_MSG);&lt;/P&gt;&lt;P&gt;  TimerCount = 0;&lt;/P&gt;&lt;P&gt;  n = 0;&lt;/P&gt;&lt;P&gt;  configI2C1(400); // configure I2C baud rate for 400 KHz&lt;/P&gt;&lt;P&gt;  write1I2C1(MMA8452Q_ADDR, WHO_AM_I); // read device ID register&lt;/P&gt;&lt;P&gt;  read1I2C1(MMA8452Q_ADDR, &amp;amp;Accel_ID);&lt;/P&gt;&lt;P&gt;  write2I2C1(MMA8452Q_ADDR, CTRL_REG1, 0x18); // ODR=100Hz, LNOISE=0,&lt;/P&gt;&lt;P&gt;F_READ=0, ACTIVE=0&lt;/P&gt;&lt;P&gt;  write2I2C1(MMA8452Q_ADDR, FF_MT_CFG, 0xD8); // ELE=1, OAE=1, ZEFE=0,&lt;/P&gt;&lt;P&gt;YEFE=1, XEFE=1&lt;/P&gt;&lt;P&gt;  write2I2C1(MMA8452Q_ADDR, FF_MT_THS, 0x30); // 3g/0.063g=47.6 (round up&lt;/P&gt;&lt;P&gt;to 48), Threshold &amp;gt; 3g&lt;/P&gt;&lt;P&gt;  write2I2C1(MMA8452Q_ADDR, FF_MT_COUNT, 0x0A); // set debounce counter to&lt;/P&gt;&lt;P&gt;eliminate false readings for 100Hz sample rate with requirement of 100 ms&lt;/P&gt;&lt;P&gt;timer&lt;/P&gt;&lt;P&gt;  write2I2C1(MMA8452Q_ADDR, CTRL_REG4, 0x04); // disable auto SLEEP/WAKE&lt;/P&gt;&lt;P&gt;interrupt, enable FF_MT interrupt&lt;/P&gt;&lt;P&gt;  write2I2C1(MMA8452Q_ADDR, CTRL_REG5, 0x04); // FF_MT interrupt output&lt;/P&gt;&lt;P&gt;signal assigned to INT1 pin of MMA8452Q&lt;/P&gt;&lt;P&gt;  write2I2C1(MMA8452Q_ADDR, CTRL_REG1, 0x19); // put MMA8452Q in ACTIVE&lt;/P&gt;&lt;P&gt;mode&lt;/P&gt;&lt;P&gt;printf("WHO_AM_I = %#5x\n",Accel_ID);&lt;/P&gt;&lt;P&gt;readRTCC();&lt;/P&gt;&lt;P&gt;printf("The Time is: %02d:%02d:%02d\n",HOUR,MIN,SEC);&lt;/P&gt;&lt;P&gt;printf("The Date Is: %02d/%02d/%02d\n", MTH,DAY,YR);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while(1)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;if (TimerCount % 1000 == 0)&lt;/P&gt;&lt;P&gt;   {&lt;/P&gt;&lt;P&gt;    write1I2C1(MMA8452Q_ADDR, OUT_X_MSB);&lt;/P&gt;&lt;P&gt;    read1I2C1(MMA8452Q_ADDR, &amp;amp;XrawData1);&lt;/P&gt;&lt;P&gt;    write1I2C1(MMA8452Q_ADDR, OUT_X_LSB);&lt;/P&gt;&lt;P&gt;    read1I2C1(MMA8452Q_ADDR, &amp;amp;XrawData2);&lt;/P&gt;&lt;P&gt;    write1I2C1(MMA8452Q_ADDR, OUT_Y_MSB);&lt;/P&gt;&lt;P&gt;    read1I2C1(MMA8452Q_ADDR, &amp;amp;YrawData3);&lt;/P&gt;&lt;P&gt;    write1I2C1(MMA8452Q_ADDR, OUT_Y_LSB);&lt;/P&gt;&lt;P&gt;    read1I2C1(MMA8452Q_ADDR, &amp;amp;YrawData4);&lt;/P&gt;&lt;P&gt;    write1I2C1(MMA8452Q_ADDR, OUT_Z_MSB);&lt;/P&gt;&lt;P&gt;    read1I2C1(MMA8452Q_ADDR, &amp;amp;ZrawData5);&lt;/P&gt;&lt;P&gt;    write1I2C1(MMA8452Q_ADDR, OUT_Z_LSB);&lt;/P&gt;&lt;P&gt;    read1I2C1(MMA8452Q_ADDR, &amp;amp;ZrawData6);&lt;/P&gt;&lt;P&gt;    Xout_12_bit = (XrawData1&amp;lt;&amp;lt;8 | XrawData2)&amp;gt;&amp;gt;4;&lt;BR /&gt; Yout_12_bit = (YrawData3&amp;lt;&amp;lt;8 | YrawData4)&amp;gt;&amp;gt;4;&lt;BR /&gt; Zout_12_bit = (ZrawData5&amp;lt;&amp;lt;8 | ZrawData6)&amp;gt;&amp;gt;4;&lt;/P&gt;&lt;P&gt;    printf("Xout_12_bit = %#6x\n", Xout_12_bit);&lt;/P&gt;&lt;P&gt;    printf("Yout_12_bit = %#6x\n", Yout_12_bit);&lt;/P&gt;&lt;P&gt;    printf("Zout_12_bit = %#6x\n", Zout_12_bit);&lt;/P&gt;&lt;P&gt;    write1I2C1(MMA8452Q_ADDR, INT_SOURCE);&lt;/P&gt;&lt;P&gt;    read1I2C1(MMA8452Q_ADDR, &amp;amp;IntSourceSystemRegData);&lt;/P&gt;&lt;P&gt;    if ((IntSourceSystemRegData &amp;amp; 0x04)==0x04)&lt;/P&gt;&lt;P&gt;     {&lt;/P&gt;&lt;P&gt;        n++;&lt;/P&gt;&lt;P&gt;        readRTCC(); // read real time clock and calendar&lt;/P&gt;&lt;P&gt;        printf("MOTION DETECTION n=%d %02d:%02d:%02d\n",n,HOUR,MIN,SEC);&lt;/P&gt;&lt;P&gt;        write1I2C1(MMA8452Q_ADDR, FF_MT_SRC);&lt;/P&gt;&lt;P&gt;        read1I2C1(MMA8452Q_ADDR, &amp;amp;FFMT_IntSourceReg_data); // read the&lt;/P&gt;&lt;P&gt;FF_MT_SRC register to clear the interrupt&lt;/P&gt;&lt;P&gt;     }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   }&lt;/P&gt;&lt;P&gt; }  // end of while(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;} // end of main&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the screenshot of what my PC displays when I run the above&lt;/P&gt;&lt;P&gt;algorithm (while keeping the MMA8452Q perfectly level and still):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reset cause: Power-on.&lt;/P&gt;&lt;P&gt;Device ID = 0x00000675 (PIC24HJ64GP502), revision 0x00003003 (A3)&lt;/P&gt;&lt;P&gt;Fast RC Osc with PLL&lt;/P&gt;&lt;P&gt;main.c, built on May 28 2015 at 01:29:52&lt;/P&gt;&lt;P&gt;WHO_AM_I =  0xff&lt;/P&gt;&lt;P&gt;The Time is: 01:30:00&lt;/P&gt;&lt;P&gt;The Date Is: 05/28/15&lt;/P&gt;&lt;P&gt;Xout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Yout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Zout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;MOTION DETECTION n=1, time is 01:30:01&lt;/P&gt;&lt;P&gt;Xout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Yout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Zout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;MOTION DETECTION n=2, time is 01:30:02&lt;/P&gt;&lt;P&gt;Xout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Yout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Zout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;MOTION DETECTION n=3, time is 01:30:03&lt;/P&gt;&lt;P&gt;Xout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Yout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Zout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;MOTION DETECTION n=4, time is 01:30:04&lt;/P&gt;&lt;P&gt;Xout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Yout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Zout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;MOTION DETECTION n=5, time is 01:30:05&lt;/P&gt;&lt;P&gt;Xout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Yout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Zout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;MOTION DETECTION n=6, time is 01:30:06&lt;/P&gt;&lt;P&gt;Xout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Yout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Zout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;MOTION DETECTION n=7, time is 01:30:07&lt;/P&gt;&lt;P&gt;Xout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Yout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;Zout_12_bit = 0xffff&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see, the WHO_AM_I register reads 0xff and not 0x2a,  and the 12&lt;/P&gt;&lt;P&gt;bit acceleration registers all read 0xffff (indicating -0.002g). The I1&lt;/P&gt;&lt;P&gt;interrupt pin read 3.3 volts constantly. My PIC microcontroller operates at&lt;/P&gt;&lt;P&gt;3.3 volts just as does the MMA8452Q accelerometer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice that you could offer would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bryan Bennett&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Wed, May 27, 2015 at 5:18 AM, TomasVaverka &amp;lt;admin@community.freescale.com&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 05:35:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396203#M1509</guid>
      <dc:creator>bryanbennett</dc:creator>
      <dc:date>2015-05-28T05:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: MMA8452Q accelerometer</title>
      <link>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396204#M1510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bryan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While looking at the definition of the &lt;A href="https://engineering.purdue.edu/ece477/Archive/2009/Spring/S09-Grp06/Code/PIC/pic24_code_examples/docs/pic24__i2c_8c-source.html#l00176"&gt;write1I2C1()&lt;/A&gt; function you are using to read MMA8452Q registers, I realized that the problem most likely comes from a stop condition, that is generated instead of a repeated start condition, between the second (register address) and third byte (0x3B if SA0 = 1). So try to remove the stopI2C1() routine from the definition of the write1I2C1() function and also make sure that the third byte is really 0x3B ((0x1D &amp;lt;&amp;lt; 1 ) | 0x01) and not 0x3A.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the problem still persists, I will need a screenshot illustrating the complete read transaction to see what is going on on the bus.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 08:50:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Sensors/MMA8452Q-accelerometer/m-p/396204#M1510</guid>
      <dc:creator>TomasVaverka</dc:creator>
      <dc:date>2015-05-28T08:50:03Z</dc:date>
    </item>
  </channel>
</rss>

