SPI connection between Arduino Uno and DAC80504evm

Hello everyone,

I am working with Arduino Uno and DAC80504EVM, and I would like to connect them via SPI.
Since I am at the beginning stage of understanding SPI, I would like to establish a simple communication, where I send a voltage level from Arduino to SPI, and then from the output 0 of the DAC (DAC0), I get the voltage that I read on the analog pin (A0) of the Arduino board.

So far, I have tried it, but unsuccessfully. Here is code that I have been trying out, and the image of connections between the devices I am sending you attached:

// inslude the SPI library:
#include <SPI.h>

const int slaveSelectPin = 10;
int sensorPin = A0;
int sensorValue = 0;

void setup() {
Serial.begin(9600);
// set the slaveSelectPin as an output:
pinMode(slaveSelectPin, OUTPUT);
// initialize SPI:
SPI.beginTransaction(SPISettings(50000000, MSBFIRST, SPI_MODE0));
}

void loop() {
// take the SS pin low to select the chip:
digitalWrite(slaveSelectPin, LOW);

// send in the address and value via SPI:
SPI.transfer(0x08); // because the address of DAC0 register is 1000
SPI.transfer(0x00); // upper byte of data
SPI.transfer(0x08); // lower part of data (randomly chosen)

sensorValue = analogRead(sensorPin); // read data from A0
Serial.println(sensorValue*5.0/1023.0);

// take the SS pin high to de-select the chip:
digitalWrite(slaveSelectPin, HIGH);

}

When I run this code, and try to see what will I get when I change to what I connect the A0 pin (for example, I try to connect it to SCLK) and I don't get the pulsing signal on the serial plotter, instead I get some kind of random signal. I am sending you attached also the output of serial plotter when I connect A0 to SCLK, SDO, SDI, CS and Vref.

I would very much appreciate it if somebody could provide me with information if I am doing this correctly, or how should I change my code?

Thanks everyone in advance. I would appreciate any comment or suggestion.

Kind regards,

Dejana

Please edit your post and insert code tags!

SPI.beginTransaction(SPISettings(50000000, MSBFIRST, SPI_MODE0));

The UNO has a CPU clock of 16MHz so it's impossible for it to have a 50MHz SPI clock.

When I run this code, and try to see what will I get when I change to what I connect the A0 pin (for example, I try to connect it to SCLK) and I don't get the pulsing signal on the serial plotter, instead I get some kind of random signal.

Sorry, but quite a stupid idea. You're using the SPI interface, so the SCLK signal will be much faster than the analog inputs can digitize a signal.

If you want to use that sketch, connect A0 to a voltage divider containing a potentiometer to adjust the input voltage.

Why do you connect VDD/VIO to 3.3V if you connect the SPI pins directly (resulting in an IO voltage of 5V)? If you actually did that you might have damaged the DAC.

Although on the wiring diagram the Vdd is connected to some LEDs...