Hi all, I wonder is people could point me in the right direction.
I am attempting to read multiple bytes of data coming back on a modified SPI interface from a combined GPS, Acellerometer, Compass, Thermometer sensor module from Dimitech.
http://www.dimitech.com/downloads/dtx1-2820l.pdf
I'm having a hell of a time with it.
I thought I would start small and just read back the configuration of the GPS module on the board, using the Address/Command structure from the data sheet.
Which I take to mean, pull the CS low, send the Address (0x30), send the register to read (0x40, GPS mode register). It will then send the "dummy" packing byte of 0xFF, the data "payload" and then its own address (0x30 again) to signal the final packet.
Below is my code which is a mashup of a tronixstuff tutorial and the SparkFun ADXL345_Basic.pde
/*
Example 34.1 - SPI bus demo using a Microchip MCP4162 digital potentiometer [http://bit.ly/iwDmnd]
http://tronixstuff.com/tutorials > chapter 34 | CC by-sa-nc | John Boxall
*/
#include "SPI.h" // necessary library
char values[3];
void setup()
{
pinMode(10, OUTPUT); // we use this for SS pin
SPI.begin(); // wake up the SPI bus.
SPI.setBitOrder(LSBFIRST);
SPI.setDataMode(SPI_MODE1);
SPI.setClockDivider(8);
digitalWrite(10, LOW);
SPI.transfer(0x30); //address byte
SPI.transfer(0x73); //GPS Mode Register
SPI.transfer(0x02); //Set 10Hz update mode
digitalWrite(10, HIGH);
Serial.begin(9600);
}
void loop()
{
digitalWrite(10, LOW);
SPI.transfer(0x30);
//Continue to read registers until we've read the number specified, storing the results to the input buffer.
for(int i=0; i<3; i++){
values[i] = SPI.transfer(0x70); //GPS Status Read byte
}
digitalWrite(10, HIGH);
for(int i=0; i<3; i++){
Serial.println(values[i], HEX);
}
Serial.println("Hello?");
delay(1000);
}
And a sample of what I see in the serial monitor window.
FFFFFFFF
FFFFFFFF
FFFFFFFF
Hello?
FFFFFFFF
FFFFFFFF
FFFFFFFF
Hello?
FFFFFFFF
FFFFFFFF
FFFFFFFF
Hello?
I believe I am supposed to receive back an 0xFF (dummy byte), 0x02 (10Hz mode) and finally 0x30, its address signalling the end of the transfer.
Any suggestions?
Cheers
Gregg.