SPI communication with IMU ADIS16480

Status
Not open for further replies.

MGA

New member
Great job with the Teensy 3.0.

I'm trying now to integrate an ADIS16480 from Analog Devices with the Teensy 3.0 but no matter what I do, the IMU doesnt answer. I know it works because I can test it in another device and it works perfectly.

I have used some libraries (SDFAT and cmason), mix everything, etc. but still does not work.

Enclosed the teensySPI.c and .h. And my main():
int main(void) {

short count = 0;
char msg[64];
uint8_t buffOut[8];
uint8_t buffIn[8];
int value;
short i;

// Serial Init
serial_begin(9600);
serial_print("Hello World\n");

// SPI Init
pinMode (chipSelect, OUTPUT);
digitalWriteFast(chipSelect, HIGH);

SPIbegin();
SPIinit(SPI_CLOCK_DIV16);
SPIsetDataMode(SPI_MODE3);


// SPI comm
buffOut[0] = 0x80; buffOut[1] = 0x00;
buffOut[2] = 0x00; buffOut[3] = 0x00;

digitalWrite(chipSelect, LOW);
SPIsendMultiple(buffOut, 4);
digitalWrite(chipSelect, HIGH);

while (1) {

// SPI comm
digitalWrite(chipSelect, LOW);
delayMicroseconds(4);
buffOut[0] = 0x80; buffOut[1] = 0x00;
buffOut[2] = 0x00; buffOut[3] = 0x00;
SPIsendMultiple(buffOut, 4);
delayMicroseconds(4);
digitalWrite(chipSelect, HIGH);

delayMicroseconds(25);

digitalWrite(chipSelect, LOW);
delayMicroseconds(4);
buffOut[0] = 0x7E; buffOut[1] = 0x00;
buffOut[2] = 0x00; buffOut[3] = 0x00;
SPIsendMultiple(buffOut, 4);
delayMicroseconds(4);
digitalWrite(chipSelect, HIGH);

delayMicroseconds(25);

digitalWrite(chipSelect, LOW);
delayMicroseconds(4);
buffOut[0] = 0x22; buffOut[1] = 0x00;
buffOut[2] = 0x00; buffOut[3] = 0x00;
SPIsendMultiple(buffOut, 4);
delayMicroseconds(4);
digitalWrite(chipSelect, HIGH);

delayMicroseconds(25);

}

return 0;

}

The specs of the IMU is in this link (http://www.analog.com/static/imported-files/data_sheets/ADIS16480.pdf). The characteristics
- SPI Mode 3
- MSB-First Mode
- 16-bit mode

I have tried to change the configurations of the registers SPI0_MCR and SPI0_CTAR0/1. Without any success.

Has anyone already got an ADIS IMU working with a Teensy 3.0? Could anyone help?

Thanks in advance.
 

Attachments

  • teensySPI.c
    7.8 KB · Views: 547
  • teensySPI.h
    2 KB · Views: 264
Hi,

Some questions - does the Teensy produce the right signals on the way to the IMU? In other words, have you verified with a logic analyzer that these non-standard commands work?

The reason I say this is while using the SDfat library may add some nifty features, you may be better off using traditional SPI commands instead. Also, if those delays are based on an arduino AVR code expectation, then you may have to fiddle with the length a bit to see when you get the right one... IIRC, the Teensy 3 has a much more accurate clock than the Arduino in terms of scheduling, so a 4ms delay on the Arduino might be called with a delay (1) command, while on the Teensy 3 it has to be delay(4).

While re-writing the code to not use the SDFat library may be a bit of an inconvenience, it may very well help you trouble-shoot the problem.
 
Thanks Constantin,

enclosed you can find a screen capture of a logic analyzer. To me, they seem like perfect signal conditions for SPI mode 3.
Capture2.jpg

I did not use standard SPI library because I dont know how to transfer 16 bits at once and receive also 16 bits per transfer() call.
 
View attachment teensy3.zipWell,

I got it finally working. The screen capture was ok. There were some other problems with connectors and also the stubbornness of this IMU for communicating in not perfect conditions.

However, because it took me so much time to have it working, and there is not much support on the web for SPI communication with 16bits and this IMU, I include enclosed to this post the code working producing the timing diagram of my previous post.

Best regards.
 
I did not use standard SPI library..I have tried to change the configurations thats why
 
Status
Not open for further replies.
Back
Top