MMA8451Q Data access using interrupt

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

MMA8451Q Data access using interrupt

跳至解决方案
2,000 次查看
anhnguyen
Contributor I

Hi all, i'm using MMA8451Q.
I'm accessing  data via hardware interrupt.
After i activate MMA8451Q , it asserts SRC_DRDY interrupt bit  indicating the presence of new data and/or data overrun.

I have tried to clear this bit by reading the X, Y, and Z data as datasheet said (page 25).

But this bit has not been cleared.

Any body, please tell me what is wrong here and what should i do?

Thanks,

标记 (1)
0 项奖励
1 解答
1,239 次查看
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi,


Please make sure you read out all the OUT_X_MSB, OUT_Y_MSB and OUT_Z_MSB registers. You can use either a single multiple-byte read operation or read out those registers using a single byte read as shown in the below simple examples.

1.

Data_Ready = IIC_RegRead(MMA8451_IIC_ADDRESS, INT_SOURCE_REG);  

if (Data_Ready & 0x01)                                                                                            //Is new set of data ready?

      {

        IIC_RegReadN(MMA8451_IIC_ADDRESS, OUT_X_MSB_REG, 6, &AccData[0]);

        PTCD = PTCD ^ 0x01;   

      }

2.

Data_Ready = IIC_RegRead(MMA8451_IIC_ADDRESS, INT_SOURCE_REG);  

if (Data_Ready & 0x01)                                                                                            //Is new set of data ready?

      {

        IIC_RegRead(MMA8451_IIC_ADDRESS, OUT_X_MSB_REG );

        IIC_RegRead(MMA8451_IIC_ADDRESS, OUT_Y_MSB_REG );

        IIC_RegRead(MMA8451_IIC_ADDRESS, OUT_Z_MSB_REG );

        PTCD = PTCD ^ 0x01;

      }

I toggled the PTC0 pin to monitor the SRC_DRDY bit on my o-scope.

Hopefully this makes sense, but let me know if the problem continues.


Regards,

Tomas

在原帖中查看解决方案

0 项奖励
3 回复数
1,240 次查看
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi,


Please make sure you read out all the OUT_X_MSB, OUT_Y_MSB and OUT_Z_MSB registers. You can use either a single multiple-byte read operation or read out those registers using a single byte read as shown in the below simple examples.

1.

Data_Ready = IIC_RegRead(MMA8451_IIC_ADDRESS, INT_SOURCE_REG);  

if (Data_Ready & 0x01)                                                                                            //Is new set of data ready?

      {

        IIC_RegReadN(MMA8451_IIC_ADDRESS, OUT_X_MSB_REG, 6, &AccData[0]);

        PTCD = PTCD ^ 0x01;   

      }

2.

Data_Ready = IIC_RegRead(MMA8451_IIC_ADDRESS, INT_SOURCE_REG);  

if (Data_Ready & 0x01)                                                                                            //Is new set of data ready?

      {

        IIC_RegRead(MMA8451_IIC_ADDRESS, OUT_X_MSB_REG );

        IIC_RegRead(MMA8451_IIC_ADDRESS, OUT_Y_MSB_REG );

        IIC_RegRead(MMA8451_IIC_ADDRESS, OUT_Z_MSB_REG );

        PTCD = PTCD ^ 0x01;

      }

I toggled the PTC0 pin to monitor the SRC_DRDY bit on my o-scope.

Hopefully this makes sense, but let me know if the problem continues.


Regards,

Tomas

0 项奖励
1,239 次查看
bergo
Contributor III

I'm wondering,

what is the PTC0 pin?

0 项奖励
1,239 次查看
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Bergo,

I have used this pin just to monitor the SRC_DRDY bit, it does not have any connection with the previous instructions that are necessary to deassert the interrupt. You can ignore this line of the code - PTCD = PTCD ^ 0x01

Regards,

Tomas

0 项奖励