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,
已解决! 转到解答。
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
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
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