Hi!
I encountered a problem while trying to read data from an SPI device from my teensy 3.0.
My goal is to read values from an 9-DOF IMU over SPI (YEI 3-Space embedded IMU). All data regarding this IMU is provided here:
http://tech.yostengineering.com/3-space-sensor/product-family/embedded
(Data Mode 0, up to 6MHz).
I successfully tested this device using an MBED board. I was able to write data (e.g. set led color on the IMU board) and read data (e.g. quaternions).
So basically I know this IMU works. When "contacting" the device, it returns various bytes to display its state. Returned byte values usually are between 0 and 4.
To make it short, returned byte values from SPI.transfer always were 255. I Checked the wiring and soldering several times, but nothing changed.
In order to find out if it was an issue with my SPI understanding or if the teensy was damaged, I've tested a Sparkfun 7-segment display, URL:
https://www.sparkfun.com/products/11442
together with the code samples provided by sparkfun. It works like a charm. So writing data over SPI to the slave device seems to work.
Next, I tried out an SPI-Gyro from Polulu, but i also didn't receive anything else than "255". Disconnecting the DIN-pin also didn't affect my reading - stil 255.
My device connections were:
CS0 (pin 10) = slave select, pulled low for communication
DOUT/DIN (pins 11, 12) for communications
pin 13 = sck
I use power supply from the pins provided at that side of the teensy where the USB connector is provided (3.3 V (100 mA max, should be OK), Gnd).
Here is the code for the YEI three space IMU. This code should initiate the transmission of the Hardware serial number. However, bytes returned should be something lik 0 (Idle), 4 (aggregating command bytes), 2 (processing command)
Until now, I don't have a logic analyzer - if I checked wiring long enough, I didn't need it yet. Therefore, I can't provide Oscilloscope readings. Does somebody know what is going on?
I encountered a problem while trying to read data from an SPI device from my teensy 3.0.
My goal is to read values from an 9-DOF IMU over SPI (YEI 3-Space embedded IMU). All data regarding this IMU is provided here:
http://tech.yostengineering.com/3-space-sensor/product-family/embedded
(Data Mode 0, up to 6MHz).
I successfully tested this device using an MBED board. I was able to write data (e.g. set led color on the IMU board) and read data (e.g. quaternions).
So basically I know this IMU works. When "contacting" the device, it returns various bytes to display its state. Returned byte values usually are between 0 and 4.
To make it short, returned byte values from SPI.transfer always were 255. I Checked the wiring and soldering several times, but nothing changed.
In order to find out if it was an issue with my SPI understanding or if the teensy was damaged, I've tested a Sparkfun 7-segment display, URL:
https://www.sparkfun.com/products/11442
together with the code samples provided by sparkfun. It works like a charm. So writing data over SPI to the slave device seems to work.
Next, I tried out an SPI-Gyro from Polulu, but i also didn't receive anything else than "255". Disconnecting the DIN-pin also didn't affect my reading - stil 255.
My device connections were:
CS0 (pin 10) = slave select, pulled low for communication
DOUT/DIN (pins 11, 12) for communications
pin 13 = sck
I use power supply from the pins provided at that side of the teensy where the USB connector is provided (3.3 V (100 mA max, should be OK), Gnd).
Here is the code for the YEI three space IMU. This code should initiate the transmission of the Hardware serial number. However, bytes returned should be something lik 0 (Idle), 4 (aggregating command bytes), 2 (processing command)
Code:
#include "SPI.h"
// Pin definitions
const int SSpin = 10;
int i=0;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(SSpin, OUTPUT);
Serial.begin(9600);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV8);
SPI.setDataMode(SPI_MODE0);
digitalWrite(SSpin, HIGH);
}
// the loop routine runs over and over again forever:
void loop() {
if (Serial.available())
{
//wait until connection established, user entered any char
Serial.println("Enter");
char ch = Serial.read();
delayMicroseconds(200);
int a;
// initiate communication
digitalWrite(SSpin, LOW);
delay(1);
// Tell the slave that a command is transmitted, device should return 0
ch = SPI.transfer(0xE6);
a = ch;
Serial.println (a);
delay(1);
// Tell the slave to send Hardware serial
ch = SPI.transfer(0xF6);
a = ch;
Serial.println (a);
delay(1);
// Send 0xFF until command processed, return value 2.
ch = SPI.transfer(0xFF);
a = ch;
Serial.println (a);
delay(1);
// end communication, further data reading needs to be established
digitalWrite(SSpin, HIGH);
delay(1);
}
delay(500); // wait for a second*/
}
Until now, I don't have a logic analyzer - if I checked wiring long enough, I didn't need it yet. Therefore, I can't provide Oscilloscope readings. Does somebody know what is going on?