1. Have you checked with a logic analyzer if the CS and CLK signals are working well?
2. Is there any difference between the frequencies of the Arduino environment and Mraa/node.js?
3. Also, could you tell us which image are you using? As well as the version of mraa and node.js.
I have checked CS/CLK signals with logic analyzer.
And the data to/from MAA7455L looks fine.
It looks normal SPI signal.
OS version : yocto linux release 2.1
node version : v0.10.38
mraa version : 'v0.8.0'
New information !!
I have tried to change the interval between SPI transactions.
( /CS set 1 -> /CS to 0 and exchanging data -> /CS to 1 -> usleep(500000) )
this '500000' micro seconds interval is inserted after every SPI trancaction.
If I set the interval timer over 30000 micro seconds -> SPI signal is bad
example : usleep(30000)
If I set the interval timer under 20000 micro seconds -> works well
example : usleep(20000)
It seems long "usleep" function cause a bad effect to SPI signals or MAA7455L's behavior.
I have no idea why "usleep" function efects to SPI signals........
With edison-arduino-environment, "delay(500)" function cause no effect to SPI and run normaly.
I want to keep "500000" micro seconds (0.5 seconds) interval between every transactions.
I don't know what causes this and how to fix it.
I get confused.....
I would suggest you to use the latest stable version of node, which I believe is 0.12.0, you can check that information in their website.
Also, did you make sure to configure the pins of the Arduino Expansion Board accordingly? You can check how this is done following this link: http://www.emutexlabs.com/project/215-intel-edison-gpio-pin-multiplexing-guide. There you can find the Edison multiplexing Guide, and one of the examples explains how to configure the pins for SPI use (Example 5 – the first instruction should be corrected to echo 111 > /sys/class/gpio/export).
About the differences between using numbers over 30000, I’m not sure what could be causing this. We will investigate this further.
I will try the version 0.12.0 later.
By the way, I found a page referring about MMA7755L.
(japanese page... please translate with translator like bing)
This site says that MMA7455L could have a habit, which need a dummy reading
before writing a setup-data.
I have experimented.
Valid : if reading a dummy-data before writing setup-data.
It is re-initialized if make a interval over 30000us.
Invalid : if no dummy data.
Valid : after reading some data.
So I think that MMA7455L works almost well (reading and writing).
But it seems to need a read proccess (normal reading or dummy reading)
before writing the setup-data with mraa.
In edison-arduino-environment, there is no need pre-reading, and works well.
And every SPI pin's setting might be right with node-version 0.10.38, too.
I wonder why there is need a reading-proccess with mraa library.
Is there any difference between mraa and arduino-environment?
Both mraa and arduino programs have gcc compiled binary in itself,
so I think there are no difference between them.
It could be caused by a tiny timing jitter for only MMA7455L ???
I have tried to update node.js to 0.12.0, but I couldn't find how to update node 0.12.0.
I tried to handle spi and mraa with python in the same way.
Result : same to node.js !
(1) with pre-reading before writing setup-data
---> working good
(2) without pre-reading before writing setup-data
---> not working
(3) with long interval from reading(30000 micro seconds)
---> not working
So it may not caused only with node.js.
mraa library? mraa wrapper?...........
Is there a way to examine what causes the behavior?
I have no way to do.
Thank you for your help.
I think I have not distinguished the problem caused with only my device or every same devices.
It can be special for only my device. (or for some defective products of MMA7455L)
So I think there is a possibility not to solve it.
I want to try with another MMA7455L, If I would get another MMA7455L.
(Now I have only one device.)
By the way,
I have mistaken the device name. It's not "MAA7455L", It's "MMA7455L". sorry.
It could be possible that it is something with your device, but some issues have been reported with SPI in release 2.1. I would suggest to try downgrading to the previous image.
Another option would be to write a C code and use the Arduino spidev library as a guide given that the example works well in the Arduino IDE. Which Arduino IDE are you using? In case you’re using 1.6.5, check this path \Users\<username>\AppData\Roaming\Arduino15\packages\Intel\hardware\i686\1.6.2+1.0\libraries\SPI\src\SPI.cpp which uses /linux/spidev.h.
I have checked the version of Arduino IDE. -> 1.6.4
And found the path to spidev.h in SPI.cpp.
> #include <linux/spi/spidev.h>
But I'm not good at x86 assembly language or runtime libraries of x86.
(I know AVR environment, so I have made some spi programs for
Arduino/AVR with C or assembly language.)
I have tried to read SPI.cpp, but I can't understand the detail of what the
spidev.h/SPI.cpp does instantly.
(I don't know what the tags/functions/variables means)
For the present, I will try the previous version of yocto image.
I'm sorry I'm late.
I have tried old yocto image and old mraa library.
I was looking for old OS images, but I could find only yocto 2.0 image,
so I installed yocto 2.0 image and tested.
--> mraa version = v0.7.2
Result : same to v0.8.0.
It could not be caused only with mraa of yocto 2.1.
This could happen not only edison but also other micro controller,
so the cause could be "not" in edison, mraa, node.js, yocto linux......
(mentioned in a japanese site)
I have searched other reports of MMA7455L with SPI, but I have not found.
Have you considered using I2C instead of SPI? According to the datasheet, both protocols are supported. Another option would be to contact the manufacturer or their forums, maybe they can provide a different input.
I have tried with I2C.
(1) arduino (at-mega328 3.3V 8MHz)
---> runs normally, ofcourse.
(long interval, short interval)
(2) edison with arduino-environment
--->runs normally like arduino.
(3) edison with node.js, mraa
---> runs normally like arduino.
So I think that it would be caused only with SPI.
But I can't conclude which causes the behavior with "mraa library" or "MMA7455L".