AnsweredAssumed Answered

External Programming AD5504 Eval Board

Question asked by AleRfmicro on Oct 6, 2017
Latest reply on Oct 6, 2017 by AleRfmicro

Hi,

I'm trying to program via external SPI the AD5504 DAC (Eval Board). At the moment i'm using Arduino "Uno" as microcontroller with SPI logic level of 5V.

 

Hardware configuration:

LK1 removed

LK9 at position C

LK10 at position C

I provided VDD and VLOGIC (5V) form external DC power suppply

 

Software configuration:

i'm trying to write first the control register by sending 0x7004 hex code and then i want to write the dac register by sending 0x1200. i verified that it correspond to a 3.75V on DAC1 output (by using eval board usb connection).

 

So i write this simple code. Arduino is 8-bit microcontroller and DAC requires 16bit register. but in the datasheet it is written that not-continuous CLK is allowed. the LDAC pin is normally High and only in the DAC write method is put low.

 

#define dataout 11 //MOSI
#define datain 12 //MISO
#define sclk 13 //sck
#define csPin 10 //ss
#define lDac 9 //lDac


#include <SPI.h> //Includo libreria predefinata Arduino

void setup() { //

SPI.begin(); //Init
SPI.setBitOrder(MSBFIRST); //Definisce Most/Less Significant Bit ordine
SPI.setClockDivider(4); //Divisore di Clock. Default == 4, sequenza due byte clock separati; Divider == 2, 16 fronti di clock consecutivi
pinMode(csPin,OUTPUT); //Pin CS è definito come Out
pinMode(lDac,OUTPUT); //Pin CS è definito come Out
pinMode(dataout,OUTPUT); //Pin MOSI è definito come Out
pinMode(datain,INPUT); //Pin MISO è definito come In
digitalWrite(csPin, HIGH); //Disabilita Slave con CS == High
digitalWrite(lDac, HIGH); //Disabilita Slave con CS == High

}

void loop() { //Programma Principale
//for(int i=0; i<1023; i++) {
digitalCTRLWrite(0,i); //Richiama metodo per scrittura registri CTRL
digitalDACWrite(0,i); //Richiama metodo per scrittura registri DAC
//delay(1);
//}
}

void digitalCTRLWrite(int address, int valore) { //Metodo Scrittura
digitalWrite(csPin, LOW); //Abilita Slave con CS == Low
byte byte1 = 0x70; //Definisco primo Byte: 8bit
byte byte0 = 0x04; //Definisco secondo Byte: 8bit
SPI.transfer(byte1); //Transfer Primo byte (MSB)
SPI.transfer(byte0); //Transfer Secondo byte (MSB)
digitalWrite(csPin, HIGH); //Disabilita Slave con CS == High e permette scrittura registro

}

void digitalDACWrite(int address, int valore) { //Metodo Scrittura
digitalWrite(csPin, LOW); //Abilita Slave con CS == Low
byte byte1 = 0x12; //Definisco primo Byte: 8bit
byte byte0 = 0x00; //Definisco secondo Byte: 8bit
SPI.transfer(byte1); //Transfer Primo byte (MSB)
SPI.transfer(byte0); //Transfer Secondo byte (MSB)
digitalWrite(csPin, HIGH); //Disabilita Slave con CS == High e permette scrittura registro
digitalWrite(lDac, LOW); //Disabilita Slave con CS == High

}

 

I didn't see anything on the DAC1 output.

what's wrong?

can you help me?

 

Regards

Outcomes