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
3,653 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
1 Solution
2,892 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
3 Replies
2,893 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
2,892 Views
bergo
Contributor III

I'm wondering,

what is the PTC0 pin?

0 Kudos
2,892 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
%3CLINGO-SUB%20id%3D%22lingo-sub-185500%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMMA8451Q%20Data%20access%20using%20interrupt%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-185500%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20all%2C%20i'm%20using%20MMA8451Q.%3CBR%20%2F%3EI'm%20accessing%26nbsp%3B%20data%20via%20hardware%20interrupt.%3CBR%20%2F%3EAfter%20i%20activate%20MMA8451Q%20%2C%20it%20asserts%20SRC_DRDY%20interrupt%20bit%26nbsp%3B%20indicating%20the%20presence%20of%20new%20data%20and%2For%20data%20overrun.%3C%2FP%3E%3CP%3EI%20have%20tried%20to%20clear%20this%20bit%20by%20reading%20the%20X%2C%20Y%2C%20and%20Z%20data%20as%20datasheet%20said%20(page%2025).%3C%2FP%3E%3CP%3EBut%20this%20bit%20has%20not%20been%20cleared.%3C%2FP%3E%3CP%3EAny%20body%2C%20please%20tell%20me%20what%20is%20wrong%20here%20and%20what%20should%20i%20do%3F%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-185503%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA8451Q%20Data%20access%20using%20interrupt%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-185503%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Bergo%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20have%20used%20this%20pin%20just%20to%20monitor%20the%20SRC_DRDY%20bit%2C%20it%20does%20not%20have%20any%20connection%20with%20the%20previous%20instructions%20that%20are%20necessary%20to%20deassert%20the%20interrupt.%20You%20can%20ignore%20this%20line%20of%20the%20code%20-%20PTCD%20%3D%20PTCD%20%5E%200x01%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ETomas%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-185502%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA8451Q%20Data%20access%20using%20interrupt%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-185502%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI'm%20wondering%2C%3C%2FP%3E%3CP%3Ewhat%20is%20the%20%3CSPAN%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20background-color%3A%20%23ffffff%3B%22%3EPTC0%20pin%3C%2FSPAN%3E%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-185501%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA8451Q%20Data%20access%20using%20interrupt%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-185501%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EHi%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EPlease%20make%20sure%20you%20read%20out%20all%20the%20OUT_X_MSB%2C%20OUT_Y_MSB%20and%20OUT_Z_MSB%20registers.%20You%20can%20use%20either%20a%20single%20multiple-byte%20read%20operation%20or%20read%20out%20those%20registers%20using%20a%20single%20byte%20read%20as%20shown%20in%20the%20below%20simple%20examples.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E1.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EData_Ready%20%3D%20IIC_RegRead(MMA8451_IIC_ADDRESS%2C%20INT_SOURCE_REG)%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3Eif%20(Data_Ready%20%26amp%3B%200x01)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2FIs%20new%20set%20of%20data%20ready%3F%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegReadN(MMA8451_IIC_ADDRESS%2C%20OUT_X_MSB_REG%2C%206%2C%20%26amp%3BAccData%5B0%5D)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3EPTCD%20%3D%20PTCD%20%5E%200x01%3B%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E2.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EData_Ready%20%3D%20IIC_RegRead(MMA8451_IIC_ADDRESS%2C%20INT_SOURCE_REG)%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3Eif%20(Data_Ready%20%26amp%3B%200x01)%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2FIs%20new%20set%20of%20data%20ready%3F%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegRead(MMA8451_IIC_ADDRESS%2C%20OUT_X_MSB_REG%20)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegRead(MMA8451_IIC_ADDRESS%2C%20OUT_Y_MSB_REG%20)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IIC_RegRead(MMA8451_IIC_ADDRESS%2C%20OUT_Z_MSB_REG%20)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3C%2FSPAN%3EPTCD%20%3D%20PTCD%20%5E%200x01%3B%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20toggled%20the%20PTC0%20pin%20to%20monitor%20the%20SRC_DRDY%20bit%20on%20my%20o-scope.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%2010.0pt%3B%20font-family%3A%20'Arial'%2C'sans-serif'%3B%22%3EHopefully%20this%20makes%20sense%2C%20but%20let%20me%20know%20if%20the%20problem%20continues.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22mce_paste_marker%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22mce_paste_marker%22%3ERegards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22mce_paste_marker%22%3ETomas%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E