Hi. I am trying to get 0 to 10V out of AD5761. I have Vdd= 12V; Vref = 2.5V and DVcc = 5V with Alert!, Clear! and Reset! all left floating. I have the following arduino code that's supposed to program the chip, but for some reason it is not working. Can somebody please tell me what I'm doing wrong here?
Thank you!!
#include <SPI.h> //include SPI library
const int syncPin = 10;
const int LDACPin = 9;
void setup() {
Serial.begin(9600);
pinMode(syncPin, OUTPUT);
pinMode(LDACPin, OUTPUT);
digitalWrite(syncPin, HIGH);
digitalWrite(LDACPin, LOW);
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV128);
SPI.setDataMode(SPI_MODE0);
digitalWrite(syncPin, LOW);
SPI.transfer(0x07); //software reset
SPI.transfer16(0x0000);
digitalWrite(syncPin, HIGH);
digitalWrite(syncPin, LOW);
SPI.transfer(0x04); //write to control register
SPI.transfer16(0x00A1); //0000000010100001;
digitalWrite(syncPin, HIGH);
}
void loop() {
digitalWrite(syncPin, LOW);
int data = 0x2222; //some random value
byte highByte = (data & 0xFF00)>>8; //high byte of data
byte lowByte = (data & 0x00FF)<<0; //low byte of data
//Now send it
SPI.transfer(0x03);
SPI.transfer(highByte);
SPI.transfer(lowByte);
digitalWrite(syncPin, HIGH);
}

corrected typo
[edited by: asymptote_99 at 3:40 AM (GMT -4) on 22 Sep 2021]