can't read valid data from MMA9555L

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

can't read valid data from MMA9555L

2,334 Views
miladfcb91
Contributor I

Hi everyone,

I'm working with MMA9555L module through an i2c interface, but I'm having a problem with pedometer function in MMA9555L. For a sanity check, I read back the version information which is ok and gets back the desired data but when I want to read the data from pedometer application, the slave returns nonsense data. Here is my code:

void main()

{

   void pedometerConfigRegs();           //sets the configuration registers of the pedometer application

                                                             //send these bytes to the part: 0x15, 0x20, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00,                                                                   0x00, 0x00, 0xE0, 0x00, 0xB6, 0x44, 0x04, 0x83, 0x05, 0x82, 0x00, 0x00, 0x00

   void pedometerReadValue();            //reads back from the slave

                                                             //send these bytes to the part: 0x15, 0x30, 0x00, 0x0C

   while(1)

   {

      read_i2c(16);

   }

}

Any help is highly appreciated.

Regards,

Milad.

Labels (2)
Tags (2)
0 Kudos
2 Replies

2,118 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello milad,

in order for the information to be updated, the COCO flag should be 1,

so a fix delay between write and read will ensure the data is correct,

the delay must be > 33ms.

Also, did you put the device out of sleep mode, before setting the pedometer function, which is its state out of reset?

For that you'll need to clear the bit 0 of the CFG register.

As for the error code, it is possible that the comand you are sending is incorrect,

could you share the modifications you did?

Thank you!

Regards,

Aldo

0 Kudos

2,118 Views
miladfcb91
Contributor I

After some modifications, now the slave returns error 0x9C instead of 0x80 which shows "the command interpreter does not recognize a command code."

How can I fix this problem?

0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-799174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ecan't%20read%20valid%20data%20from%20MMA9555L%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-799174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20everyone%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI'm%20working%20with%20MMA9555L%20module%20through%20an%20i2c%20interface%2C%20but%20I'm%20having%20a%20problem%20with%20pedometer%20function%20in%20MMA9555L.%20For%20a%20sanity%20check%2C%20I%20read%20back%20the%20version%20information%20which%20is%20ok%20and%20gets%20back%20the%20desired%20data%20but%20when%20I%20want%20to%20read%20the%20data%20from%20pedometer%20application%2C%20the%20slave%20returns%20nonsense%20data.%20Here%20is%20my%20code%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Evoid%20main()%3C%2FP%3E%3CP%3E%7B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3Bvoid%20pedometerConfigRegs()%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%2F%2Fsets%20the%20configuration%20registers%20of%20the%20pedometer%20application%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%2F%2Fsend%20these%20bytes%20to%20the%20part%3A%26nbsp%3B0x15%2C%200x20%2C%200x00%2C%200x11%2C%200x00%2C%200x00%2C%200x00%2C%200x00%2C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B0x00%2C%200x00%2C%200xE0%2C%200x00%2C%200xB6%2C%200x44%2C%200x04%2C%200x83%2C%200x05%2C%200x82%2C%200x00%2C%200x00%2C%200x00%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3Bvoid%20pedometerReadValue()%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%2F%2Freads%20back%20from%20the%20slave%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%2F%2Fsend%20these%20bytes%20to%20the%20part%3A%200x15%2C%200x30%2C%200x00%2C%200x0C%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3Bwhile(1)%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%7B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20read_i2c(16)%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%7D%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAny%20help%20is%20highly%20appreciated.%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EMilad.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-799174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAccelerometers%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EGyroscope%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-799176%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20can't%20read%20valid%20data%20from%20MMA9555L%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-799176%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20milad%2C%3C%2FP%3E%3CP%3Ein%20order%20for%20the%20information%20to%20be%20updated%2C%20the%20COCO%20flag%20should%20be%201%2C%3C%2FP%3E%3CP%3Eso%20a%20fix%20delay%20between%20write%20and%20read%20will%20ensure%20the%20data%20is%20correct%2C%3C%2FP%3E%3CP%3Ethe%20delay%20must%20be%20%26gt%3B%2033ms.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAlso%2C%20did%20you%20put%20the%20device%20out%20of%20sleep%20mode%2C%20before%20setting%20the%20pedometer%20function%2C%20which%20is%20its%20state%20out%20of%20reset%3F%3C%2FP%3E%3CP%3EFor%20that%20you'll%20need%20to%20clear%20the%20bit%200%20of%20the%20CFG%20register.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAs%20for%20the%20error%20code%2C%20it%20is%20possible%20that%20the%20comand%20you%20are%20sending%20is%20incorrect%2C%3C%2FP%3E%3CP%3Ecould%20you%20share%20the%20modifications%20you%20did%3F%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3EAldo%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-799175%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20can't%20read%20valid%20data%20from%20MMA9555L%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-799175%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EAfter%20some%20modifications%2C%20now%20the%20slave%20returns%20error%200x9C%20instead%20of%200x80%20which%20shows%20%22the%20command%20interpreter%20does%20not%20recognize%20a%20command%20code.%22%3C%2FP%3E%3CP%3EHow%20can%20I%20fix%20this%20problem%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E