MMA8653FC communication problems

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

MMA8653FC communication problems

1,654 Views
garryblair
Contributor II

Hi!

I have some issues communicating with the MMA8653FC Accelerometer chip with I2C.

To keep it simple, for now I am trying to read the WHO_AM_I register

I took a look at the signal on the scope, and from what I can see its OK, but I am receiving 00 all the time.

Some observations:

- I am not sure if I need to activate the chip (from register 0x2A) before reading the WHO_AM_I but it seems to make a difference. If its activated I receive 0xFF, and if I don't I receive 0x00.

- I tried adding some delays, but I can't see any difference really.

- I compared my scope signal to a picture of what the WHO_AM_I reading process is meant to look like, and as far as I am aware it is OK

- My sequence is: Initialize I2C at 400Khz, activate accelerometer in register 0x2A, read from the WHO_AM_I register

- There is definately some communication, I receive Acks

- I am using a small board with our MCU on it, with wires that are a few cm long to a board with the accelerometer. I am happy to send you any schematics if it will help

- I know there is some overshoot on the screenshot of the scope, I soldered wires onto my board so I could attach my scope probes, I think its because of that.

20150520_141838.jpg

I have used the same I2C drivers in a few projects now so I think they are ok. It is an ARM cortex M0

I really have no idea why it doesn't work - any one have any idea?

Labels (1)
Tags (2)
8 Replies

1,100 Views
jamesbone
NXP TechSupport
NXP TechSupport

Oh, if both devices had the pull-up resistors the bus it is not having the proper impedance and capacitance required, removed the resistors from the other device and try again please.

0 Kudos
Reply

1,100 Views
garryblair
Contributor II

Hi,

I removed the resistors from the other device but it unfortunately made no difference.

Actually we have used another I2C device connected to the same board before that has worked OK.

I feel like im missing something fundamental here - is there any setup or anything else I need to do in my code? From looking at example code, I can't see anything i'm doing wrong / missing

0 Kudos
Reply

1,100 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Garry,

First, sorry for not responding sooner, I have been out of the office the last couple of days.

Looking at your first screen shot, I have noticed that you are sending the stop condition (a LOW to HIGH transition of SDA while SCL is HIGH) after the second byte (0x0D) instead of sending the repeated start condition. So, please try to modify your source code so that SDA transitiones to HIGH before the SCL goes HIGH in order to eliminate the stop condition.

I hope it helps.

Regards,

Tomas

PS: If my answer helps to solve your question, please mark it as "Correct". Thank you.

0 Kudos
Reply

1,100 Views
garryblair
Contributor II

Tomas,

I found that in my code, it was waiting for "no master activity on the bus" before doing the read command - it was something from example code. I'm not sure why, but removing this made it work

Maybe it made the stop condition - the MCU I am using doesn't go into detail on their implementation so I really don't get what this "wait for no master activity on the bus" means

Thanks for your help! It works great now

1,100 Views
jonr
Contributor III

I had the same problem.  Luckily, the i2c library I am using allows me to do "Wire.endTransmission (I2C_NOSTOP,1000);" which fixed it.  Thanks!

0 Kudos
Reply

1,100 Views
jamesbone
NXP TechSupport
NXP TechSupport

Hello Garry,

I am not able to see from your screen shot the frequency of the I2C clock, just to review that it is in the 400Khz,   something that maybe working incorrect it is the address of the device what  address are you using? again in the picture it is not clear if we are looking to the first part of the command.

0 Kudos
Reply

1,100 Views
garryblair
Contributor II

Hi,

I have taken screen shots of the write and read phase separately for the WHO_AM_I register

20150521_084256.jpg

This is the write phase. I am writing to the register 0x0D (WHO_AM_I) to device address 0x1D.

The device acknowledges and as far as I can see the data is as it should be. You can also see that the clock is 400Khz

read.jpg

This is the read phase. Again I am sending the address 0x1D. You can see that the data I am reading is 00 which is incorrect. The WHO_AM_I register should be 0x5A but you can see here I get 0x00. I can't see what I am doing wrong

The only thing I am doing before reading this register is sending a reset command to CTRL_REG2. The interesting thing here is if I don't send this reset command, I receive 0xFF instead of 0x00

I really can't see what is wrong here. I am also comparing what signals I receive against this picture I found on the forums:

IMG_20052015_120810.png

And to me, they seem to match

Again, please let me know if I can provide any additional information.

One last thing, we do have another device on the same I2C bus (EEPROM) which works fine. It has a different address, but I noticed it also has 4.7k resistors (the same as we put on our accelerometer chip). I can't see this causing a problem, but I thought id mention it in case

0 Kudos
Reply

1,100 Views
garryblair
Contributor II

Hi,

Sorry that the picture isnt clear - the clock speed is 400Khz

The picture should show the sequence for reading the WHO_AM_I register - so a write and read cycle

The address I used was 0x1D I think (im not by my computer) but it is correct I think because the chip acknowkedges.

If I can get you another other information to help you, let me know. I will try to send you a better screenshot...the problem is it doesn't all fit on the screen

0 Kudos
Reply