MMA8451Q: I2C PROBLEM: Reading communication with mma8451Q Accelerometer and msp430

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

MMA8451Q: I2C PROBLEM: Reading communication with mma8451Q Accelerometer and msp430

865 Views
j_reig_eng
Contributor I

Hi all,

I implemented an accelerometer MMA8451Q with a MSP430F5419.

I'm trying to read the accelerometer register via I2c which is its communication protocol but it is not reading the correct value.

reading a pre-establish register for example device id the lecture are wrong, ¿some ideas to fix this issue?

I check SDA and SCL with oscilloscope the signals are correct. interrupts are enabled.

And ports configuration are like this.

Anyone can help to solve

Writing a register i see the correct bytes send to accelerometer and ack as well.

To read register the bytes send by msp are correct but the bytes received by the msp are wrong.

i hope this clarify the issue.

Thanks in advance

0 Kudos
3 Replies

619 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi William,

If you have an oscilloscope or a logic analyzer, can you please post here a plot illustrating what is going on the bus when you read the WHO_AM_I (0x0D) register?

 

To read the WHO_AM_I register (when SA0 = 0) you have to:

 

  1. Send a start sequence
  2. Send 0x38 // slave address with the R/W bit low or 0x1C<<1
  3. Send 0x0D //address of the WHO_AM_I register
  4. Send a start sequence again (repeated start)
  5. Send 0x39 // slave address with the R/W bit high or (0x1C<<1)|0x01
  6. Read data byte from the 0x0D register
  7. Send NAK and the stop sequence.

 

Here is an example for the MMA8652FC whose ID is 0x4A and the 7-bit slave address 0x1D:

Who_Am_I+register+read.JPG.jpg

 

A common problem with the read operation is incorrectly sending a stop condition (a low to high transition of SDA while SCL is high) instead of a repeated start condition after the second byte (in this case 0x0D). The correct way is to release the SDA line (so that it transitiones to high) before the SCL line goes high. 

Best regards,

Tomas

0 Kudos

619 Views
j_reig_eng
Contributor I

Hi tomas,

i attached a picture of  Who_am_i register(0x0D) the expected value would be 0x1A but the value read are is 0xE9+NAK.reading Who_Am_I.JPG

Slave addres is 0x1D

But the accelerometer take the first 7 bits.

0 Kudos

619 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi William,

If the 7-bit slave address is 0x1D (SA0 = 1), you should:

  1. Send a start sequence
  2. Send 0x3A // slave address with the R/W bit low or 0x1D<<1
  3. Send 0x0D //address of the WHO_AM_I register
  4. Send a start sequence again (repeated start)
  5. Send 0x3B // slave address with the R/W bit high or (0x1D<<1)|0x01
  6. Read data byte from the 0x0D register
  7. Send NAK and the stop sequence.

Looking at the screenshot, the first byte seems to be 0x1C which is wrong. You need to modify your source code so that it corresponds to the sequence above.

Best regards,

Tomas

0 Kudos