READ DATA OF MMA8452

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

READ DATA OF MMA8452

1,239 Views
594160903
Contributor I

    I am a rookie of using MMA8452, I want to read data of mma8452 to know the x,y,z;But I read data is always F and 4095,

please help me , thanks!!!

void Multiple_Read_MMA8452(void)
{
uchar i;
MMA8452_Start(); 
MMA8452_SendByte(0x38 )
MMA8452_SendByte(0x01);
MMA8452_Start(); 
MMA8452_SendByte(0x38 +1);
for (i=0; i<6; i++) 
{
BUF[i] = MMA8452_RecvByte(); 
if (i == 5)
{
MMA8452_SendACK((BitAction)1); 
}
else
{
MMA8452_SendACK((BitAction)0);
}
}
MMA8452_Stop(); 
Delay5ms();
}


void Init_MMA8452(void)
{
Single_Write_MMA8452(0x2A,0x01); //
Single_Write_MMA8452(0x2B,0x02); //

}

0 Kudos
1 Reply

1,011 Views
david_diaz
NXP Employee
NXP Employee

Hello,

Thank you very much for writing.

In this case, I’d like to recommend the application note AN4076 below:

Data Manipulation and Basic Settings of the MMA8451, 2, 3Q

This application note accompanies the MMA8451, 2, 3Q Driver Code and will explain the following:

  • Changing the operational modes (Standby, Active 2g, Active 4g and Active 8g)
  • Changing Oversampling Modes
  • Changing the Data Rate
  • Changing the High-Pass Filter Cutoff Frequency
  • 8-bit data vs. 14/12/10-bit data
  • Changing Data Formats (hex to counts to decimal numbers)
  • Streaming XYZ data polling vs. Streaming XYZ data with interrupts
  • Using the FIFO in the MMA8451

 

Besides, you may use the sample project below as a reference for your application.

MMA8451Q - Bare metal example project

 

Please let me know if you have any further question.

Regards,

David

0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-642695%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EREAD%20DATA%20OF%20MMA8452%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-642695%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3BI%20am%20a%20rookie%20of%20using%20MMA8452%2C%20I%20want%20to%20read%20data%20of%20mma8452%20to%20know%20the%20x%2Cy%2Cz%3BBut%20I%20read%20data%20is%20always%20F%20and%204095%2C%3C%2FP%3E%3CP%3Eplease%20help%20me%20%2C%20thanks!!!%3C%2FP%3E%3CP%3Evoid%20Multiple_Read_MMA8452(void)%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%20uchar%20i%3B%3CBR%20%2F%3E%20MMA8452_Start()%3B%26nbsp%3B%3CBR%20%2F%3E%20MMA8452_SendByte(0x38%3CSPAN%20class%3D%22%22%3E%20%3C%2FSPAN%3E)%3CBR%20%2F%3E%20MMA8452_SendByte(0x01)%3B%3CBR%20%2F%3E%20MMA8452_Start()%3B%26nbsp%3B%3CBR%20%2F%3E%20MMA8452_SendByte(0x38%3CSPAN%20class%3D%22%22%3E%20%3C%2FSPAN%3E%2B1)%3B%3CBR%20%2F%3E%20for%20(i%3D0%3B%20i%26lt%3B6%3B%20i%2B%2B)%26nbsp%3B%3CBR%20%2F%3E%20%7B%3CBR%20%2F%3E%20BUF%5Bi%5D%20%3D%20MMA8452_RecvByte()%3B%26nbsp%3B%3CBR%20%2F%3E%20if%20(i%20%3D%3D%205)%3CBR%20%2F%3E%20%7B%3CBR%20%2F%3E%20MMA8452_SendACK((BitAction)1)%3B%26nbsp%3B%3CBR%20%2F%3E%20%7D%3CBR%20%2F%3E%20else%3CBR%20%2F%3E%20%7B%3CBR%20%2F%3E%20MMA8452_SendACK((BitAction)0)%3B%3CBR%20%2F%3E%20%7D%3CBR%20%2F%3E%20%7D%3CBR%20%2F%3E%20MMA8452_Stop()%3B%26nbsp%3B%3CBR%20%2F%3E%20Delay5ms()%3B%20%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3Evoid%20Init_MMA8452(void)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%20Single_Write_MMA8452(0x2A%2C0x01)%3B%20%2F%2F%3CBR%20%2F%3E%20Single_Write_MMA8452(0x2B%2C0x02)%3B%20%2F%2F%3CBR%20%2F%3E%20%3CBR%20%2F%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-642696%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20READ%20DATA%20OF%20MMA8452%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-642696%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EThank%20you%20very%20much%20for%20writing.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EIn%20this%20case%2C%20I%E2%80%99d%20like%20to%20recommend%20the%20application%20note%20AN4076%20below%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.nxp.com%2Fassets%2Fdocuments%2Fdata%2Fen%2Fapplication-notes%2FAN4076.pdf%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EData%20Manipulation%20and%20Basic%20Settings%20of%20the%20MMA8451%2C%202%2C%203Q%3C%2FA%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EThis%20application%20note%20accompanies%20the%20MMA8451%2C%202%2C%203Q%20Driver%20Code%20and%20will%20explain%20the%20following%3A%3C%2FP%3E%3CUL%3E%3CLI%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3EChanging%20the%20operational%20modes%20(Standby%2C%20Active%202g%2C%20Active%204g%20and%20Active%208g)%3C%2FLI%3E%3CLI%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3EChanging%20Oversampling%20Modes%3C%2FLI%3E%3CLI%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3EChanging%20the%20Data%20Rate%3C%2FLI%3E%3CLI%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3EChanging%20the%20High-Pass%20Filter%20Cutoff%20Frequency%3C%2FLI%3E%3CLI%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3E8-bit%20data%20vs.%2014%2F12%2F10-bit%20data%3C%2FLI%3E%3CLI%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3EChanging%20Data%20Formats%20(hex%20to%20counts%20to%20decimal%20numbers)%3C%2FLI%3E%3CLI%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3EStreaming%20XYZ%20data%20polling%20vs.%20Streaming%20XYZ%20data%20with%20interrupts%3C%2FLI%3E%3CLI%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3EUsing%20the%20FIFO%20in%20the%20MMA8451%3C%2FLI%3E%3C%2FUL%3E%3CBR%20%2F%3E%3CP%3EBesides%2C%20you%20may%20use%20the%20sample%20project%20below%20as%20a%20reference%20for%20your%20application.%3C%2FP%3E%3CP%3E%3CA%20_jive_internal%3D%22true%22%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fdocs%2FDOC-98836%22%20target%3D%22_blank%22%3EMMA8451Q%20-%20Bare%20metal%20example%20project%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPlease%20let%20me%20know%20if%20you%20have%20any%20further%20question.%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EDavid%3C%2FP%3E%3C%2FLINGO-BODY%3E