Hello everyone. I need an ADC with more resolution than the one built in to the ATMega. I have a Texas Instruments ADS1212P that I have connected to my Arduino and I’m trying to get the two to talk via SPI, but I’m running in to issues.
If you have SDOUT connected to MISO (Master In/Slave Out) you will have to set the SDL bit of the command register to 1. The default is to use the same pin (SDIO) for Input and output.
I do have SDOUT connected to MISO. The pin definitions list reads as if using SDIO for both input and output is optional, but I see in the Command Register bit descriptions that it does both input and output by default. I have modified my code to try to blindly send the command to change that, but it doesn’t seem to be working for me. I’m still getting the same data back as I sent to the ADC.
#include <SPI.h>
#define PIN_SCK 13 // SPI clock
#define PIN_MISO 12 // SPI data input
#define PIN_MOSI 11 // SPI data output
const int dataReadyPin = 9;
const int chipSelectPin = 10;
void setup() {
Serial.begin(9600);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV128);
SPI.setDataMode(SPI_MODE1);
pinMode(dataReadyPin, INPUT);
pinMode(chipSelectPin, OUTPUT);
digitalWrite(chipSelectPin,HIGH);
while (digitalRead(dataReadyPin) == LOW) { //Wait until this goes high
delay(1);
}
digitalWrite(chipSelectPin,LOW);
Serial.println("Setting CMD:SDL");
SPI.transfer(B00000100); //Write to Command Register Byte 3
SPI.transfer(B01000010); //Set SDL to use SDOUT
digitalWrite(chipSelectPin,HIGH);
delay(250);
}
void loop() {
if (digitalRead(dataReadyPin) == HIGH) {
digitalWrite(chipSelectPin,LOW);
byte b0 = SPI.transfer(B10000000);
Serial.println(b0,BIN);
digitalWrite(chipSelectPin,HIGH);
delay(250);
}
}
So just a question.. It should be pretty much simpler to just use an external crystal, like a 2 Mhz... instead of reducing the spi port speed ?
Or have you already figure out ?