Hi,I am using the TWRVF65GS10 with MQX 4.1.But I finded no demo for MMA8451q.I try some times with Re: I2C Vybrid Code?.Vybrid can't get the ACK of MMA8451.I mant to get some surport ,documnet or code demo.
已解决! 转到解答。
Hi Li Zhenq,
I just implemented an MQX I2C demo for MMA8451Q, it is for TWR-K60D100M, but should be easily ported to TWRVF65GS10, please kindly refer to [MQX 4.1]I2C demo for MMA8451Q for more details.
Hope that helps,
Have a great day,
Kan
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Li Zhenq,
I just implemented an MQX I2C demo for MMA8451Q, it is for TWR-K60D100M, but should be easily ported to TWRVF65GS10, please kindly refer to [MQX 4.1]I2C demo for MMA8451Q for more details.
Hope that helps,
Have a great day,
Kan
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Li Zhenq,
The I2C address for MMA8451Q on TWR-VF65GS10 should be 0x1C since SA0 is pulled down by R130 by default. Have you ported the demo to TWR-VF65GS10? Maybe you can share the printf messages for a review.
Thanks for your patience!!
Have a great day,
Kan
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi
Here is some pseudocode for the initialization and sampling for the MMA8451Q
After initializing you should be able to read.
For the i2c_read and i2c_write, you can follow the implementation done for the mma7760 at <mqx_installation>/demo/accelerometer/accel_i2c.c
#define ADDR = 0x1C
typedef struct data {
char reg
char value
} data
Initialize_MMA8451Q {
data.reg = 0x11 //PL_CFG
data.val = 0xc0
i2c_write(12c0, ADDR, data, sizeof(data))
data_reg = 0x2a //CTRL_REG1
data.val = 0x01
i2c_write(12c0, ADDR, data, sizeof(data))
}
#define READ_DATA 0x01
#define READ_STATUS 0x10
sample_MMA8451Q {
char x,y,z, status;
char rcv_buf[6];
i2c_read(12c0, ADDR, READ_DATA, rcv_buf, sizeof(rcv_buf));
x = rcv_buf[0];
y = rcv_buf[2];
z = rcv_buf[4];
i2c_read(12c0, ADDR, READ_STATUS, rcv_buf, 3);
status = rcv_buf[0];
}
I will try to have get a sample version, probably by the end of next week.
Just clarification for those to reply to Li Zheng - MMA8451Q is Freescale Digital Accelerometer IC with an I2C interface (http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8451Q.pdf).