Go Down

Topic: please help, urgent, daisy chaining two AD5204 (Read 1 time) previous topic - next topic

project24

We have a question regarding daisy chaining multiple AD5204 together. The way we were doing is concatenating 22 bits and sending that to two AD5204s. The clock SPI mode was set to mode2. Only one CS line was used and is initially set to low until all the data are send to the AD5204. The ship work with out daisy chaining but when daisy chained with another ship, we seem to get the wrong output. We used arduino to control it. Bellow is our code snippet:

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

const int slaveSelectPin = 10;
const int SDIPin = 11;
const int CLKPin = 13;

void setup() {
  pinMode(slaveSelectPin, OUTPUT);
  //pinMode(SDIPin, OUTPUT);
  //pinMode(CLKPin, OUTPUT);
  SPI.setDataMode(SPI_MODE2);
  SPI.setClockDivider(SPI_CLOCK_DIV128);
  SPI.setBitOrder(MSBFIRST);
  SPI.begin();

  digitalWrite(slaveSelectPin,LOW);
  SPI.transfer(7);
  SPI.transfer(248);
  SPI.transfer(255);
  digitalWrite(slaveSelectPin,HIGH);

}

void loop() {

}


By the way, we do have a pullup resistor


johnwasser

I think the datasheet shows that the SPI clock default state is LOW and it should sample on the rising edge.  I think that's SPI_MODE0, not SPI_MODE2.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats :)

Go Up