Jump to content

I2C and MMA8452/MMA8451 accelerometer

Recommended Posts

Still new to embedded programming and I am trying to use the MMA8452 accelerometer (datasheet) on SparkFun's breakout board (link).  I programmed SparkFun's example program (link) into the MSP430G2553 via Energia with no issues and plotted the serial data in Excel.  However this data, for lack of a better word, was "noisy."  There would be huge spikes in the data even though the device was sitting still.  Sometimes the WHO_AM_I value would be reported incorrectly as well.


I found out the board shipped with 10k pull ups so I dropped them to the recommended 4.7k? resistors and the problem persisted.  When I tried to investigate the SCL and SDA lines with my oscilloscope, the problem would disappear and the data would be a pristine flat line (as expected). That told me the scope probe capacitance was actually helping the circuit and rather than decrease resistance I should increase resistance.  That seemed very counter intuitive to me, but I followed the data and changed pull ups to 15k.  The problem disappeared and the data was clean.  I was using short leads with and without a breadboard.  The jumper to the Green LED was also removed from the SCL line.


Being required to have 15k pull ups on the I2C bus seems wrong to me especially since the datasheet recommends 4.7k.  Am I missing something?  I am not well versed in I2C and Freescale's tech support has been less than helpful.  I did order a MMA8451 sample and swapped it on SparkFun's breakout board and had the same problem.  So I know the problem was not specific to that MMA8452.


Other I2C devices (like the BQ32000) work fine.


Link to post
Share on other sites

The MSP430 does support to use internal pull-up resistors on the I2C pins, if you have them enabled AND have external 4k7 resistors, you might end up with an effective pull-up resistance which is too low for the accelerometer to decently pull down the signals when transmitting data. Might this be the cause of your problem?


Line 22 of the examle program contains this comment:

The MMA8452 has built in pull-up resistors for I2C so you do not need additional pull-ups.

So... you might even end up with three pairs of pull-up resistors!

Link to post
Share on other sites

I did not even consider internal pull-up resistors.  


I have since killed my launchpad (mismanagement of a 12V wire) and have not resurrected it yet (replaced the TUSB3410 but still receive the "cannot connect to target" error).  A new one is one the way and I will make sure the internal pull ups are disabled when I try next.   

Link to post
Share on other sites
  • 4 years later...



I have a similar problem.  I have successfully built a simple game based on the MMA8451 accelerometer breakout board from Adafruit with an Arduino Uno.  I am now trying to convert the game to a Ti Launchpad using an MSP430G2553 processor but cannot communicate with the MMA8451 at all.

I have gone back to basics using the MMA8451demo.ino code (https://learn.adafruit.com/adafruit-mma8451-accelerometer-breakout/) in the Energia IDE with the MSP430 using pins P1_6 (SCL) and P1_7 (SDA) both with and without added 4K7 pullup resistors, and, although the programme compiles and runs, no acceleration outputs result in the serial monitor.

Here is the relevant part of my code:

void setup(void) {
  if (! mma.begin()) {
    Serial.println("Couldnt start");
    while (1);

  pinMode(P1_6, INPUT_PULLUP);       // and without _pullup
  pinMode(P1_7, INPUT_PULLUP);      // and without _pullup

void loop() {
  // Read the 'raw' data in 14-bit counts
  Serial.print("X:\t"); Serial.print(mma.x); 
  Serial.print("\tY:\t"); Serial.print(mma.y); 
  Serial.print("\tZ:\t"); Serial.print(mma.z); 

  /* Get a new sensor event */ 
  sensors_event_t event; 

  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("X: \t"); Serial.print(event.acceleration.x); Serial.print("\t");
  Serial.print("Y: \t"); Serial.print(event.acceleration.y); Serial.print("\t");
  Serial.print("Z: \t"); Serial.print(event.acceleration.z); Serial.print("\t");
  Serial.println("m/s^2 ");

Does anyone have some advice on the correct setup for the MSP430 that will facilitate communication with the MMA8451 please?  I suspect the problem lies with the setup code in the MSP430 but I cannot find any examples to help me.

Many thanks!


Link to post
Share on other sites
  • 2 weeks later...


My problems seem to be growing.  I have gone back to basics to try and get my project working, and this involves writing values to the serial monitor with Serial.println().  For some reason, even with the TX/RX jumpers reversed, I am having a real problem getting anything to display.  I have 3 different, new MSP430G2553 Launchpads and only one of these prints to the serial monitor, and even that not consistently.  Is it possible that I have damaged the other 2 Launchpads?

I am now seriously considering the wisdom of choosing the MSP430 platform - can't serial print and can't communicate with the Adafruit MMA8451 breakout board!!

Please help.


Link to post
Share on other sites

I have checked the pin maps! Mine is a very 1.5, so the jumpers are at right angles. I note that the forums are bursting with people who have serial monitor problems, but no solutions beyond the jumpers. This must be a known problem... I have also deleted and reinstalled CCS and Energia several times. What else is there? Have I destroyed 2 Launchpads? 

Link to post
Share on other sites

I have two MSP-EXP430G2 V1.5 LaunchPads and have used them for many years without a problem with serial print on various versions of Windows including 7, 8, and 10.  I have also made many custom boards using the G2553 without a problem.   Having said that, I would not recommend the MSP-EXP430G2 LaunchPad for developing the MSP430.  Get one of the newer LaunchPads like the F5529, FR2433, or FR6989.  They work well with Energia if you want to use that, can be used to program the G2553 if you really want to use that (and the only reason I can think of is the DIP package but it isn't that much more difficult to solder the larger SMD packages), and don't have the awful emulator that is on the MSP-EXP430G2.  Further they don't cost much more if any and TI frequently puts them on sale sometimes with free shipping.  You will have far fewer problems flashing and with serial on any of the newer LaunchPads.  I do all G2553 development by connecting to a F5529 LaunchPad.

To test your LaunchPads, pull the G2553 DIP microcontroller on the "bad" boards and put them in the good board to see if they work.  If you haven't done that before then my method is to pry them slowly by alternating between the ends with a very small screwdriver.  Be careful and insert slowly and evenly making sure all pins are seated as you go.  If they work in the good board then maybe something is wrong with the other LaunchPads.  If they don't work then probably something is wrong with G2553 - perhaps they saw more than 3.6V?  Do they still flash a LED?

Link to post
Share on other sites

Hi Fmilburn,

Thank you so much for your thoughtful and helpful post - some real advice for a change! All the microcontrollers seem to be working, and all successfully flash LEDs and other simple tasks.  I was wondering whether I had damaged some other components on the Launchpad other than the microcontroller...  

Its just the serial monitor and communications with the accelerometer that are causing me grief.  I will look to upgrading to a newer Launchpad and try again!

Many thanks,


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...