Go Down

Topic: spi, registers, and values (Read 757 times) previous topic - next topic

mike_r

Hello all, I have a ADIS16210. I am able to read from it all right, but my question comes about how do I write to the registers? I have a specific address, and a specific value, but how do I program the Arduino to do that?
Is is just 2 consecutive spi.transfers?
Here is the datasheet http://www.analog.com/static/imported-files/data_sheets/ADIS16210.pdf
look at table 23

Thanks,
Mike

CrossRoads

Pretty much - that's how you shift 16 bits out.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

mike_r

Here is the code that I have. I can read from the sensor fine, but it's still the default 1 sample per second. I would like to get 128 samples per second. Thanks!

Code: [Select]
#include <SPI.h>

int ss=10;
int ax, ax_l, ay, az;
int datax, datay, dataz;

void setup()
{
 Serial.begin (9600);
 pinMode(ss, LOW); //
 SPI.begin(); //
 SPI.setDataMode(SPI_MODE3);
 SPI.setBitOrder(MSBFIRST);  
 SPI.setClockDivider(SPI_CLOCK_DIV16);
 
 digitalWrite(ss, LOW);
 SPI.transfer(0x38);
 SPI.transfer(0x0002);
 digitalWrite(ss, HIGH);
 delay(5);
}

void loop()
{
digitalWrite(ss,LOW);
ax=SPI.transfer(0x0C);
ax_l = SPI.transfer(0);
digitalWrite(ss,HIGH);

datax=(ax<<8) | ax_l;
Serial.print("X Accel: ");
Serial.println(datax, DEC);
delay(25);
}

CrossRoads

Increase with serial port speed
decrease the SPI clock divider
reduce/delete the delays
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

dhenry, your totally useless answer has been deleted.
Moderator
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy