MMA8451Q Data access using interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MMA8451Q Data access using interrupt

Jump to solution
2,310 Views
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,

Tags (1)
0 Kudos
Reply
1 Solution
1,549 Views
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

View solution in original post

0 Kudos
Reply
3 Replies
1,550 Views
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 Kudos
Reply
1,549 Views
bergo
Contributor III

I'm wondering,

what is the PTC0 pin?

0 Kudos
Reply
1,549 Views
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 Kudos
Reply