How can I connect an ADC8686S to an Arduino Mega using SPI?

58 Views Asked by At

I am trying to connect a TI ADC8686S (datasheet here) to an Arduino Mega 2560 Rev3

I use the following code

#include <SPI.h>

const int CSPin = 53;

static int registerAdress = 0x10 << 9;
static int write_read_bit = 0 << 15;


void setup() {
  Serial.begin(9600);
  pinMode(CSPin,OUTPUT);
  digitalWrite(CSPin,HIGH);
  SPI.begin();

}

void loop() {
  int result;
  digitalWrite(CSPin,LOW);
  SPI.beginTransaction(SPISettings(10 * 1000, MSBFIRST, SPI_MODE0)); //frequency in kHz
  result = SPI.transfer16(write_read_bit + registerAdress);
  SPI.endTransaction();
  digitalWrite(CSPin,HIGH);
  Serial.println("Data read on SDOA = "+result);

}

I communicate with the ADC with SPI, with the following pinout.

Arduino Mega ADC8686S
50 SDOA
51 DB10/SDI
52 SCLK
53 CS

I power the AVDD and DVDD with 5V, DB9/BYTESEL is LOW, SER/BYTE/PAR is HIGH. Firstly, I power all my setup on, then I manually connect the RESET pin to 0V to initiate a full reset for a few seconds. Here is the output of the logic analyzer I use to monitor my setup. Here is the output of the logic analyzer I use to monitor my setup. I have also zoomed on data exchanges here and here. My input command should read the value of the 0x10 register, but I obtain different values at each time. Is my setup correct (I have supposed CPOL=0 and CPHA=0 but I am not sure)? Is it normal that I have such different output values for the same register ? Is my ADC working correctly ?

Thank you for your attention

0

There are 0 best solutions below