I'm a software engineer working with a hardware engineer and firmware engineer, and we are adding an MMA68xx to a product. The firmware engineer is doing the SPI via an FPGA, I'm writing via registers to the device - and we're trying to see why the response is always "Internal error/SPI error.". I expect it is that I'm not properly bringing the device up, but there's plenty to go wrong at the firmware level, too, so I wanted to make sure. I've searched for sample code, couldn't find any, so figured I'll ask here:
What I have done for initialization is sent the following 4 words:
0x4B10 - (write to DEVCFG register the value 0x10, meaning unsigned data and no arming).
0x4C00 - write to DEVCFG_X to use minimal filters and not in self-test
0xCD00 - same to DEVCFG_Y
0xCB30 - end initialization
Then, all the time, send 0x2005 and 0x6004 to get X and Y results. What I get back, as I said earlier, is 0x1C00, which is "Internal error/SPI error." Now, the datasheet says that this can come for a huge number of reasons - so I'm curious if there is a detailed description of the initialization process anywhere?
Thanks in advance,
Steve
解決済! 解決策の投稿を見る。
Hi,
Information (hardware and source code) is available at Automotive Sensors Tower System Module Freescale (http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=TWR-SENSOR-PAK-AUTO&tid=m32TWR).
Refer driver for MMA6800 or MMA6500.
Many Thanks,
Pascal
Thanks for the guidance,
I am using MMA6525 and unable to get the data,
Also Can I connect CS pin to ground forever as I am using one device as SPI slave ?
Hi Steven, are you still working with the MMA68XX? you wrote "0x4B10 - (write to DEVCFG ..." however... the datasheet says: DEVCFG is 0x0B, may it's an stupid question but I'll be glad if you answer that. (I guess the value is 0x0B10), and which Clock Rate did you use with the SPI? Thanks a lot!
Sorry it took me so long to get back. I don't have the code in front of me, and it's been a long time, but from what I remember:
1) The offsets of the registers is something for the FPGA which is doing the SPI. The value written will be the leftmost bits, and the upper 4 bits are instructions to the FPGA. If I can, I'll try to dig up if it has any effect, I think it's device select 0x4 and read/write 0x8, but not sure.
2) I didn't write the SPI directly (the FPGA engineer did the FPGA), but if I remember correctly it was 2Mb/s. I'll try to find that out, too, if he remembers. It's been a long time.
Steve
Hi Juan Diego,
are you still working with the sensor? I have the similar prob what Steven had...I am always getting 1C00 as a response. you were right regarding the configuration as per the datasheet the DEVCFG should be 0x0B and not 0x4B. I have the following configuration
DEVCFG: 0B10
DEVCFGx: 0C03
DEVCFG_Endinit: 0B30
Devstat: 1400
X_acceleratio req: 3004
I use a Baudrate of 0.1MHZ, CPOL: 1 and CPHA: 0. If you find any solution for the problem (or any mistakes in my configuration) can you please share. Thanks in advance
Hi Siva, reading the datasheet I found that for writing operations you need to put a 4 in OR with the address, that's why Steven uses those values. However.... I can not make it works, your configuration should be CPOL=0, CPHA = 0, MSB first, or at least that's what the 44 datasheet page says... I'll be grateful if you share some important information that you find.
Thanks in advance.
Juan
Found it - added a read to DEVSTAT at the end of initialization and it's working.