Interfacing DAC AD5360 with Arduino Mega

Hello I am trying to interface AD5360 and Arduino Mega using SPI ,

I am sending commands given as per the datasheet however not getting any analog output. RESET and BUSY pins are working as expected but when I try to toggle the GPIO of the DAC it always shoes output as low and BUSY pin always stays HIGH. I seek help in debugging this . I am attaching my code for reference .

#include<SPI.h>

int ldac = 4;
int clr = 5;
int resett = 6;
int gpio = 3;

void setup() {
// put your setup code here, to run once:
pinMode(clr, OUTPUT);
pinMode(ldac, OUTPUT);
pinMode(resett, OUTPUT);
pinMode(gpio, INPUT);
digitalWrite(ldac, HIGH);
digitalWrite(clr, HIGH);
digitalWrite(resett, HIGH);
Serial.begin(9600);
SPI.begin();
}

void loop() {

GPIO(0);
Serial.println(digitalRead(gpio));
delay(100);
GPIO(1);
Serial.println(digitalRead(gpio));
delay(100);
}


void GPIO(int i) {


digitalWrite(SS, LOW);
SPI.transfer(0x0D);

SPI.transfer(0x00);

if (i == 0) {
SPI.transfer(0x02);


}
if (i == 1) {
SPI.transfer(0x03);


}
digitalWrite(SS, HIGH);

}

Parents Reply Children