Trying to write DAC8531 with Arduino Mega using SPI

Hello,

I'm trying to interface DAC8531 with Arduino Mega trough three-wire serial interface (SPI).I've done all the connections and the sketch in ARDUINO IDE to write the values between 0 and 65535 (the input shift register of the DAC is 24 bits wide, the first six bits are “don’t cares”, the next two bits (PD1 and PD0) are control bits, the next 16 bits are the data bits-these are transferred to the DAC register on the 24th falling edge of SCLK.)

Here is the link for the datasheet of the DAC : http://www.ti.com/lit/ds/sbas192b/sbas192b.pdf

The program is:

#include "SPI.h"

int dacCSpin = 53, i;
byte data1 = 0, data2 = 0;


void setup() {
  pinMode(dacCSpin, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE1);
}

void loop() {

  for ( i = 0; i < 65355; i = i + 10) {
    data1 = highByte(i);
    data2 = lowByte(i);
   
    digitalWrite(dacCSpin, LOW);
    SPI.transfer(0b00000000);
    SPI.transfer(data1);
    SPI.transfer(data2);
    digitalWrite(dacCSpin, HIGH);
   
    Serial.print("sent to DAC: ");
    Serial.print(i);
    Serial.print("     in binary: ");
    Serial.println(i, BIN);
    Serial.println("      ");
  }
  delay (11000);
}

With this program I can see on the oscilloscope the three SPI signals that Arduino initiates but still can not write anything in the memory of the DAC.

SPI CLOCK with SPI MOSI

SPI SS-SPI MOSI

Vout DAC with SPI MOSI

Arduino's µc it's not writing in the DAC's buffer.

If someone has worked with this DAC, i would appreciate a few opinions and a little help if possible. Thanks a lot.

Do you see any serial output using that sketch? As the serial interface is never enabled it probably blocks as soon as the buffer is full.

Add

Serial.begin(115200);

to your setup().

Thanks for your answer and your time.It's not working even with this setup.

And where is the serial output?

A print screen of the serial monitor is attached in the reply.Thanks

You do know that you can copy/paste the contents of the serial monitor, don't you?

With your current program the DAC would need about 1.5 hours to reach the full output value. So you might either increase the baud rate or better increase the value in each loop by 100. Even then you have to measure quite slowly to see the correct DAC output as it will still need over 40 seconds to reach Vcc.