i got a code for this one but it seems to be not working i m reading the values from accelarometer and displaying it on the uart .........the probelm is the values are not changing+in my mma read and write function after writhing the addr (address) my program is getting stucked in i2c_wait function.i m very new to this anybody please help me out on this..........
Original Attachment has been moved to: hal_dev_mma8451.h.zip
Original Attachment has been moved to: hal_i2c.c.zip
Original Attachment has been moved to: hal_i2c.h.zip
Original Attachment has been moved to: main.c.zip
Original Attachment has been moved to: hal_dev_mma8451.c.zip
Hello,
have you enabled the accelerometer? I do it with this:
byte MMA1_Enable(void)
{
uint8_t val, res;
res = GI2C1_ReadByteAddress8(MMA8451_I2C_ADDR, MMA8451_CTRL_REG_1, &val);
if (res!=ERR_OK) {
return res;
}
val |= MMA8451_ACTIVE_BIT_MASK; /* enable device */
return GI2C1_WriteByteAddress8(MMA8451_I2C_ADDR, MMA8451_CTRL_REG_1, val);
}
Links to related articles:
Tutorial: Accelerating the KL25Z Freedom Board | MCU on Eclipse
Tutorial: Creating a Processor Expert Component for an Accelerometer | MCU on Eclipse
Extended Driver for the MMA8451Q Accelerometer | MCU on Eclipse