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
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:
Here is an example for the MMA8652FC whose ID is 0x4A and the 7-bit slave address 0x1D:
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.
i attached a picture of Who_am_i register(0x0D) the expected value would be 0x1A but the value read are is 0xE9+NAK.
Slave addres is 0x1D
But the accelerometer take the first 7 bits.
If the 7-bit slave address is 0x1D (SA0 = 1), you should:
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.