Problems in reading onboard mma8451 accelarometer from i2c in mkl25z128vlk4...??

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problems in reading onboard mma8451 accelarometer from i2c in mkl25z128vlk4...??

1,439 次查看
akshayhv
Contributor II

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

标签 (1)
0 项奖励
回复
2 回复数

947 次查看
Monica
Senior Contributor III

Hello Akshay,

was this suggestion helpful? Please keep us posted :smileywink:

Best,

Monica.

0 项奖励
回复

947 次查看
BlackNight
NXP Employee
NXP Employee

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