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.
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
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?