MMA9551 - problem to read raw XYZ asis data using AFE appllication

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

MMA9551 - problem to read raw XYZ asis data using AFE appllication

7,920 Views
januszjonski
Contributor II

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)

Labels (1)
0 Kudos
3 Replies

7,558 Views
JackITB
NXP Employee
NXP Employee

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)

pastedImage_3.png

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.

pastedImage_4.png

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:

pastedImage_5.png

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.

7,555 Views
januszjonski
Contributor II

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

[email protected]

0 Kudos

7,555 Views
JackITB
NXP Employee
NXP Employee

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.

0 Kudos
%3CLINGO-SUB%20id%3D%22lingo-sub-777905%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMMA9551%20-%20problem%20to%20read%20raw%20XYZ%20asis%20data%20using%20AFE%20appllication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-777905%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWhen%20I%20send%3C%2FP%3E%3CP%3Ecmd%3A%200x98%2C%200x06%2C%200x30%2C0x12%2C0x06%3C%2FP%3E%3CP%3Eans%3A%200x99%2C%200x06%2C%200x40%2C%200x02%2C%200x01%2C%200x06%2C%200x03%2C%200x41%20-%20looks%20like%20ans%20on%20APP_ID_0%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMaybe%20my%20initialization%20is%20failed%3A%3C%2FP%3E%3CP%3E1.%20Verify%20ID%20-%20OK%20(APP_ID_0)%3C%2FP%3E%3CP%3E2.%20Set%20range%20%2B%2F-2g%20(AFE)%3C%2FP%3E%3CP%3E3.%20Set%20ODR%20(AFE)%3C%2FP%3E%3CP%3E4.%20Set%20MBOX%20(I%20tried%20without%20it%20as%20well)%3C%2FP%3E%3CP%3E5.%20Run%20mode%20(APP%20SLEEP%20WAKE)%3C%2FP%3E%3CP%3E6.%20Read%20data%20(AFE%2C%20cmd%200x30)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-777905%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3ESensing%20Platforms%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-777908%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA9551%20-%20problem%20to%20read%20raw%20XYZ%20asis%20data%20using%20AFE%20appllication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-777908%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Janusz%2C%3CBR%20%2F%3EThanks%20for%20your%20feedback.%3C%2FP%3E%3CP%3ERegarding%20your%20last%20status%3A%20%22MMA%20gives%20me%20all%20the%20time%20the%20same%20value%20(I%20started%20measurement%20clearing%20SNCEN%20bit)%22%2C%20definitely%20this%20should%20not%20be%20the%20case%20!%3CBR%20%2F%3EI%20suggest%20you%20to%20check%20that%20%22Disable%20Sleep%20Mode%22%20command%20was%20successful%20by%20reading%20the%20COCO%20flag%20(0x80%20-%26gt%3B%20Command%20Completed%20without%20error).%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-size%3A%208.5pt%3B%22%3EWrite%4000%20%3A%2012%2020%2006%2001%2000%20%2F%2F%20Disable%20sleep%20mode%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%208.5pt%3B%22%3ERead%4000%26nbsp%3B%20%3A%2012%2080%2001%2001%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2F%2F%20Confirms%20the%20command%20was%20%3C%2FSPAN%3Eexecuted%20successfully%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EFor%20the%20record%2C%20I'm%20attaching%20a%20pdf%20document%20that%20illustrates%20various%20transactions%20for%20both%20I2C%2FSPI%20slave%20interfaces.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ENote%20that%20answer%20to%20a%20command%20will%20typically%20need%26nbsp%3Bseveral%20ms%20to%20be%20available%2C%20so%20you%20may%20have%20to%20introduce%20a%20delay%20before%20querying%20the%20result%2C%20or%20repeat%20the%20query%20till%20COCO%20flag%20is%20set.%26nbsp%3BUsing%20the%20MBOX%20Configuration%20Application%20(App_ID%200x18)%2C%20you%20can%20also%20program%20the%20INT_O%20pin%20so%20that%20it%20toggles%20when%20Command%20is%20completed.%20This%20provides%20a%20hardware%20line%20to%20trigger%20the%20host%20MCU%20read%20transaction.%3C%2FP%3E%3CP%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3E%3C%2FP%3E%3CP%20style%3D%22margin-bottom%3A%20.0001pt%3B%22%3E%3CSPAN%3ERegards%2C%26nbsp%3B%26nbsp%3B%26nbsp%3BJacques.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-777907%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA9551%20-%20problem%20to%20read%20raw%20XYZ%20asis%20data%20using%20AFE%20appllication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-777907%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDear%20Jacques%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3Ethank%20you%20very%20much%20for%20your%20help.%20Right%20now%20I%20am%20able%20to%20write%20and%20read%20data%20to%20register%2C%20MMA9551%20gives%20me%20correct%20answer.%3C%2FP%3E%3CP%3EI%20don%E2%80%99t%20know%20why%2C%20but%20when%20I%20read%20raw%20axis%20data%2C%20MMA%20gives%20me%20all%20the%20time%20the%20same%20value%20(I%20started%20measurement%20clearing%20SNCEN%20bit%20)%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EI%20think%20that%20you%20should%20add%20information%20inside%20user%20manual%20(MMA955xLSWRM%20point%203.1)%3A%3C%2FP%3E%3CP%3E1.%20Bytes%20to%20send%200x98%20%7C%200x00%200x00%2C%200x00%2C%200x00%2C%200x0C%20-%20No%20info%20about%20additional%20byte%20(starting%20register%20address)%3C%2FP%3E%3CP%3E2.%20Reading%20bytes%20needs%20second%20cmd%2C%20(repeated%20start%20doesn%E2%80%99t%20work).%20%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%09a.%20Cmd%200x98%2C%200x06%2C%200x30%2C0x12%2C0x06%3C%2FP%3E%3CP%3E%09b.%20Ans%3A%200x98%2C%200x00%2C%200x99%2C%200x06%2C%200x80%2C%200x06%2C%200x06%2C%200x00%2C%200x27%2C%200x00%2C%200x9D%2C%200xFD%2C%200xEB%22%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CP%3EJanusz%20Jo%C5%84ski%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EProfBox%20Janusz%20Jo%C5%84ski%3C%2FP%3E%3CP%3ENIP%3A%20728-254-86-68%3C%2FP%3E%3CP%3Etel.%3A%20(%2B48)%20607%20710%20286%3C%2FP%3E%3CP%3Ealeja%20Politechniki%2011%2C%3C%2FP%3E%3CP%3E93%20-%20590%20%C5%81%C3%B3d%C5%BA%2C%3C%2FP%3E%3CP%3Eprofbox.pl%3C%2FP%3E%3CP%3Ejj%40profbox.pl%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-777906%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MMA9551%20-%20problem%20to%20read%20raw%20XYZ%20asis%20data%20using%20AFE%20appllication%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-777906%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20Janusz%2C%3C%2FP%3E%3CP%3EI'm%20afraid%20you're%20not%20using%20the%20appropriate%20message%20syntax%26nbsp%3Bto%20communicate%20with%20MMA9551L%3A%3C%2FP%3E%3CP%3E%22cmd%3A%200x98%2C%200x06%2C%200x30%2C0x12%2C0x06%22%20is%20not%20correct%20(assuming%20it%20represents%20the%20I2C%20multi-byte%20write%20transaction).%3C%2FP%3E%3CP%3EYou%20need%20to%20specify%20the%20%3CSTRONG%3Estarting%20register%20address%3C%2FSTRONG%3E%20(usually%200x00%20i.e.%20Mailbox0)%20where%20you%20want%20to%20write%20the%20command%2C%20which%20gives%3A%3C%2FP%3E%3CP%3E%3CSPAN%3E%22cmd%3A%200x98%2C%20%3CSTRONG%3E0x00%3C%2FSTRONG%3E%2C%200x06%2C%200x30%2C%200x12%2C%200x06%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EWith%20such%20command%2C%20the%20host%20is%20requesting%20to%20AFE%20application%20(ID%200x06)%2C%206%20bytes%20of%20data%2C%20starting%20at%20status%20register%200x12%20(i.e.%20output%20%5BFRONTEND_Stage_0_GM%5D%5BXYZ%5D%20registers%2C%20cf%20MMA955xL_SWRM.pdf%20%C2%A78.3.4)%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_3.png%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_3.png%22%20style%3D%22width%3A%20649px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F14566i10B932C962B303D4%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22pastedImage_3.png%22%20alt%3D%22pastedImage_3.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAnswer%20from%20MMA9551%20device%20can%20be%20read%20by%20the%20following%20transaction%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%22ans%3A%200x98%2C%200x00%2C%200x99%2C%200x06%2C%200x80%2C%200x06%2C%200x06%2C%20%3CSTRONG%3E0x00%2C%200x27%2C%200x00%2C%200x9D%2C%200xFD%2C%200xEB%3C%2FSTRONG%3E%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ELast%206%20bytes%20are%20the%20XYZ%20data%2C%20but%20as%20the%20MMA9551L%20is%20still%20in%20sleep%20mode%2C%20they%20are%20not%20relevant.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_4.png%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_4.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F14623iC61C487BD9A18127%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22pastedImage_4.png%22%20alt%3D%22pastedImage_4.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ETo%20actually%20start%20measurement%2C%20you%20shall%20disable%20the%20SNCEN%20bit%20in%20the%20Sleep-Wake%20Application%20config%20register%2C%20with%20the%20below%20command%3A%3C%2FP%3E%3CP%3E%3CSPAN%3E%22cmd%3A%200x98%2C%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E0x00%3C%2FSTRONG%3E%3CSPAN%3E%2C%200x12%2C%200x20%2C%200x06%2C%200x01%2C%200x00%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EIf%20you%20have%26nbsp%3Bthe%20complete%20KITMMA9551LEVM%20demoboard%2C%20I%20can%20send%20you%20the%20%22Mailbox%20Tool%22%20basic%20SW%20to%20communicate%20with%20the%20device%20from%20a%20Windows%20computer%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_5.png%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22pastedImage_5.png%22%20style%3D%22width%3A%20942px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F14671i8337A3E076B58F26%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22pastedImage_5.png%22%20alt%3D%22pastedImage_5.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAfter%20the%20%22disable%20sleep%20mode%22%20command%2C%20the%20XYZ%20data%20new%20values%20are%20sensible.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EZ%20data%20is%200x105A%20%3D%204186counts%20(about%201g%20as%20board%20is%20horizontal)%2C%20whereas%20X%20and%20Y%20are%20close%20to%200g.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ENote%20that%20I've%20shown%20so%20far%20the%20%22command%2Fresponse%22%20protocol%20(2%20steps%20are%20required%20to%20get%20information%20from%20the%20MMA9551%20device%3A%20host%20sends%20a%20query%2C%20then%20reads%20the%20answer).%20You%20may%20also%20configure%20some%20of%20the%20Mailboxes%20for%20%22Quick-Read%22%20(MB20%20and%20beyond)%2C%20so%20only%20a%20read%20transaction%20is%20required%20to%20directly%20fetch%26nbsp%3Bpredefined%20sensor%20information%2Fresults.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards%2C%26nbsp%3B%26nbsp%3B%26nbsp%3BJacques.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E