Hey guys, I'm trying to figure out how to get the ADS7883 analog to digital converter (ADC) to talk to the Arduino, but I just can't seem to get it to work. The datasheet for the chip is located here. I've got pin 6 on the chip (CS) hooked up to digital pin 10, pin 5 (SDO) hooked up to digital pin 12, and pin 4 (SCLK) hooked up to digital pin 13.
In addition to that, here's my code:
#include <SPI.h>
const byte slaveSelectPin = 10; //CS
void setup() {
Serial.begin(9600);
pinMode(slaveSelectPin,OUTPUT);
digitalWrite(slaveSelectPin,HIGH); //chip active LOW
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(SPI_CLOCK_DIV16);
Serial.println("Initialized!");
}
void loop() {
long readADC = SpiRead();
Serial.println(readADC);
}
long SpiRead(void) {
long result;
long b;
digitalWrite(slaveSelectPin,LOW);
result = SPI.transfer(0xFF);
result <<= 8;
b = SPI.transfer(0xFF);
result |= b;
result = result>>2;
digitalWrite(slaveSelectPin,HIGH);
return(result);
}
All I get returned are a bunch of zeroes, but I'm pretty sure I've hooked up everything correctly. If anyone can help me out, that would be great!