When I send
cmd: 0x98, 0x06, 0x30,0x12,0x06
ans: 0x99, 0x06, 0x40, 0x02, 0x01, 0x06, 0x03, 0x41 - looks like ans on APP_ID_0
Maybe my initialization is failed:
1. Verify ID - OK (APP_ID_0)
2. Set range +/-2g (AFE)
3. Set ODR (AFE)
4. Set MBOX (I tried without it as well)
5. Run mode (APP SLEEP WAKE)
6. Read data (AFE, cmd 0x30)
Hello Janusz,
I'm afraid you're not using the appropriate message syntax to communicate with MMA9551L:
"cmd: 0x98, 0x06, 0x30,0x12,0x06" is not correct (assuming it represents the I2C multi-byte write transaction).
You need to specify the starting register address (usually 0x00 i.e. Mailbox0) where you want to write the command, which gives:
"cmd: 0x98, 0x00, 0x06, 0x30, 0x12, 0x06"
With such command, the host is requesting to AFE application (ID 0x06), 6 bytes of data, starting at status register 0x12 (i.e. output [FRONTEND_Stage_0_GM][XYZ] registers, cf MMA955xL_SWRM.pdf §8.3.4)
Answer from MMA9551 device can be read by the following transaction:
"ans: 0x98, 0x00, 0x99, 0x06, 0x80, 0x06, 0x06, 0x00, 0x27, 0x00, 0x9D, 0xFD, 0xEB"
Last 6 bytes are the XYZ data, but as the MMA9551L is still in sleep mode, they are not relevant.
To actually start measurement, you shall disable the SNCEN bit in the Sleep-Wake Application config register, with the below command:
"cmd: 0x98, 0x00, 0x12, 0x20, 0x06, 0x01, 0x00"
If you have the complete KITMMA9551LEVM demoboard, I can send you the "Mailbox Tool" basic SW to communicate with the device from a Windows computer:
After the "disable sleep mode" command, the XYZ data new values are sensible.
Z data is 0x105A = 4186counts (about 1g as board is horizontal), whereas X and Y are close to 0g.
Note that I've shown so far the "command/response" protocol (2 steps are required to get information from the MMA9551 device: host sends a query, then reads the answer). You may also configure some of the Mailboxes for "Quick-Read" (MB20 and beyond), so only a read transaction is required to directly fetch predefined sensor information/results.
Regards, Jacques.
Dear Jacques
thank you very much for your help. Right now I am able to write and read data to register, MMA9551 gives me correct answer.
I don’t know why, but when I read raw axis data, MMA gives me all the time the same value (I started measurement clearing SNCEN bit )
I think that you should add information inside user manual (MMA955xLSWRM point 3.1):
1. Bytes to send 0x98 | 0x00 0x00, 0x00, 0x00, 0x0C - No info about additional byte (starting register address)
2. Reading bytes needs second cmd, (repeated start doesn’t work).
a. Cmd 0x98, 0x06, 0x30,0x12,0x06
b. Ans: 0x98, 0x00, 0x99, 0x06, 0x80, 0x06, 0x06, 0x00, 0x27, 0x00, 0x9D, 0xFD, 0xEB"
Best regards,
Janusz Joński
ProfBox Janusz Joński
NIP: 728-254-86-68
tel.: (+48) 607 710 286
aleja Politechniki 11,
93 - 590 Łódź,
profbox.pl
jj@profbox.pl
Hi Janusz,
Thanks for your feedback.
Regarding your last status: "MMA gives me all the time the same value (I started measurement clearing SNCEN bit)", definitely this should not be the case !
I suggest you to check that "Disable Sleep Mode" command was successful by reading the COCO flag (0x80 -> Command Completed without error).
Write@00 : 12 20 06 01 00 // Disable sleep mode
Read@00 : 12 80 01 01 // Confirms the command was executed successfully
For the record, I'm attaching a pdf document that illustrates various transactions for both I2C/SPI slave interfaces.
Note that answer to a command will typically need several ms to be available, so you may have to introduce a delay before querying the result, or repeat the query till COCO flag is set. Using the MBOX Configuration Application (App_ID 0x18), you can also program the INT_O pin so that it toggles when Command is completed. This provides a hardware line to trigger the host MCU read transaction.
Regards, Jacques.