I'm getting frustrated, I bought a Parallax MMA7455 3 axis accelerometer module. I hooked up my Netduino Plus in SPI mode. Followed the Wiki's the best I could and am having issues getting data from it. Here is the links to the PDFs from parallax- module pdf and chip set PDF
The things I noticed are:
On the module I have only has 3 com connections. CLK, DATA, and CS. I read the sheet and it is supposed to automatically switch between read and write, so I put pin 11 and 12 together on the data pin.
I put pin 10 as my CS, and pin 13 as the CLK. Im using the Netduino plus 5V reg pin and GND.
the code I did looks like the following.
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace spi { public class Program { public static void Main() { // write your code here SPI.Configuration MySPI = new SPI.Configuration(Pins.GPIO_PIN_D10, false, 0, 0, true, false, 4000, SPI_Devices.SPI1); SPI spibuss = new SPI(MySPI); byte[] wb = new byte[2]; wb[0] = 0x16; //mod configuration wb[1] = 0x25; spibuss.Write(wb); while (true) { //const byte cmd_readdata = 06; byte[] WriteBuffer = { 0xff }; //send a dumb byte because you have to write somthing to the slave byte[] ReadBuffer = { 0x06 }; //read the x-axis data. spibuss.WriteRead(WriteBuffer, ReadBuffer); Debug.Print(ReadBuffer[0].ToString()); //put this data in the debug window so we can see if it is really doing anything. Thread.Sleep(1000); } } } }
I am sure its something I am messing up. I just want to keep it simple and build from that. Its how I learn the best. If anyone can help I would be so grateful. There is not many examples of c# on the web for that module yet.