0

I want to talk to an ADS8698 over SPI (see page 36 for details on their SPI implementation) using a Teensy 3.2. Right now I'm only getting zeros back and I feel like (perhaps wrongly) that I've followed the datasheet correctly. I believe my SPI mode is correct and, given the clock rates I'm using, I should be observing the timing constraints properly.

(1) Is there a glaring error here? I haven't coded that many SPI interfaces, so I might have a novice mistake in there.

(2) Is there existing code for a product that uses a nearly identical SPI interface to the ADS8698 (any product that has a similar timing diagram would do)?

#include <SPI.h>

#define USB_RATE 19200//usb transfer rate
#define SPI_CLOCK 10000000//spi clock frequency

#define CS0 10

SPISettings ADC_SPI(SPI_CLOCK, MSBFIRST, SPI_MODE1);

void setup()
{
  // disable both multiplexers
  pinMode(CS0, OUTPUT);
  digitalWrite(CS0, HIGH);
  // prepare serial protocols
  Serial.begin(USB_RATE);
  SPI.begin();
}

void read_ADC()
{
  // begin the session by taking CS0 low
  SPI.beginTransaction(ADC_SPI);
  digitalWrite(CS0, LOW);// slave select disable
  // delayMicroseconds((int) (1e6 * 20/SPI_CLOCK));// wait > 16 clock cycles
  // transfer 16 bits while the ADC performs conversion
  SPI.transfer(0); // I'm not trying to set any registers, just waiting (zero is fine)
  SPI.transfer(0); // I'm not trying to set any registers, just waiting (zero is fine)
  // data should be ready, so try to read it
  Serial.println(SPI.transfer(0));
  Serial.println(SPI.transfer(0));
  // end the session by taking CS0 high
  digitalWrite(CS0, HIGH);// slave select enable
  SPI.endTransaction();
}

void loop()
{
  delay(1000);
  read_ADC();
}

The system is wired like this:

enter image description here enter image description here

  • How have you wired it all up? – Majenko Oct 12 '16 at 17:07
  • What do have connected to analog input 0? Having 0's would be the right result it it's connected to GND. – Gerben Oct 12 '16 at 18:21
  • Hi Gerben, thanks for the response. The system certainly is not noiseless. With nothing connected there will be non-zero readings from the ADC. – nick_name Oct 12 '16 at 20:37
  • I've added the system wiring diagram. – nick_name Oct 12 '16 at 20:40
1

Per the Datasheet PG47

During power-up or reset, the default content of the command register is all 0's and the device waits for a command to be written before being placed into any mode of operation.

If your still working with this I'm going to be tackling this same thing very soon, hopefully I can get it to work with DMA. https://forum.pjrc.com/threads/34863-Teensy-CC-Dummy-Load-300W/page4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.