UDA1334 DAC Protocol

Hi All,

I’m currently trying to interface a new UDA1334ATS DAC to Arduino. I have it soldered up to a breakout board from Sparkfun to put it into a breadboard to hookup to my UNO. I tried to find some pre-written examples to get started with this, but no luck, so I had to try and come up with my own. Unfortunately, no luck and my code doesn’t work. What I want it to do is output a constant voltage off the stereo outputs, but it always seems to output 1.61V when I meter the outputs, no matter what… I think there’s an error in the way the arduino is sending out the data to the chip. I’ll post a link to the datasheet and my code if anybody would like to help out. Any help at all would be appreciated!

Thanks,

Judd

http://www.nxp.com/documents/data_sheet/UDA1334ATS.pdf

// UDA1334ATS Stereo DAC 24 Bit Example Sketch
// See the datasheet!

#define BCK 2
#define WS 3
#define DATA 4
#define LEFT HIGH
#define RIGHT LOW
#define BITS 24

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(2000);
  pinMode(WS, OUTPUT);
  digitalWrite(WS, LOW);
  pinMode(BCK, OUTPUT);
  digitalWrite(BCK, HIGH);
  pinMode(DATA, OUTPUT);
  digitalWrite(DATA, LOW);
  pinMode(A0, INPUT);
  Serial.println("Start of Sketch.");
  delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Setting DAC to 16777215");
  DACset(9999);
  Serial.println("Done.");
  Serial.println("Reading analog voltage from pin A0.");
  int val = analogRead(A0);
  Serial.print("Done. Value is ");
  Serial.println(val);
  Serial.println("End of Sketch.");
  while (1);
}

void DACset(unsigned long data) {
  int bin[BITS];
  int cnt = 0;
  for (cnt = 0; cnt <= BITS - 1; cnt++) {
    bin[cnt] = data >> cnt;
    if (bin[cnt] & 1 == 1) bin[cnt] = 1;
    else bin[cnt] = 0;
  }
  // now we have our number in binary in bin[BITS].
  // ********************* LEFT  CHANNEL ********************* //
  digitalWrite(WS, LEFT);
  for (cnt = 0; cnt <= BITS - 1; cnt++) {
    digitalWrite(BCK, LOW);
    if (bin[cnt] == 1) digitalWrite(DATA, HIGH);
    else digitalWrite(DATA, LOW);
    delayMicroseconds(100);
    digitalWrite(BCK, HIGH);
    delayMicroseconds(100);
  }
  // ********************* RIGHT CHANNEL ********************* //
  digitalWrite(WS, RIGHT);
  for (cnt = 0; cnt <= BITS - 1; cnt++) {
    digitalWrite(BCK, LOW);
    if (bin[cnt] == 1) digitalWrite(DATA, HIGH);
    else digitalWrite(DATA, LOW);
    delayMicroseconds(100);
    digitalWrite(BCK, HIGH);
    delayMicroseconds(100);
  }
  // ********************************************************* //
  digitalWrite(WS, HIGH);
  digitalWrite(DATA, LOW);
  digitalWrite(BCK, LOW);
}

The wiring is as follows (for the UDA1334):

BCK (Pin 1) —> Arduino Digital 2
WS (Pin 2) —> Arduino Digital 3
DATAI (Pin 3) —> Arduino Digital 4
VDDD (Pin 4) —> VCC (3.3V off Arduino)
VSSD (Pin 5) —> GND
SYSCLK/PLL1 (Pin 6) —> GND
SFOR1 (Pin 7) —> VCC (3.3V off Arduino)
MUTE (Pin 8) —> GND
DEEM/CLKOUT (Pin 9) —> VCC (3.3V off Arduino)
PLL0 (Pin 10) —> GND
SFOR0 (Pin 11) —> VCC (3.3V off Arduino)
VREF(DAC) (Pin 12) —> 47uF capacitor to GND
VDDA (Pin 13) —> VCC (3.3V off Arduino)
VOUTL (Pin 14) —> Arduino Analog 0
VSSA (Pin 15) —> GND
VOUTR (Pin 16) —> Unconnected

Judd: Hi All,

I'm currently trying to interface a new UDA1334ATS DAC to Arduino. I have it soldered up to a breakout board from Sparkfun to put it into a breadboard to hookup to my UNO. I tried to find some pre-written examples to get started with this, but no luck, so I had to try and come up with my own. Unfortunately, no luck and my code doesn't work. What I want it to do is output a constant voltage off the stereo outputs, but it always seems to output 1.61V when I meter the outputs, no matter what... I think there's an error in the way the arduino is sending out the data to the chip. I'll post a link to the datasheet and my code if anybody would like to help out. Any help at all would be appreciated!

Thanks,

Judd

http://www.nxp.com/documents/data_sheet/UDA1334ATS.pdf The wiring is as follows (for the UDA1334):

BCK (Pin 1) ---> Arduino Digital 2 WS (Pin 2) ---> Arduino Digital 3 DATAI (Pin 3) ---> Arduino Digital 4 VDDD (Pin 4) ---> VCC (3.3V off Arduino) VSSD (Pin 5) ---> GND SYSCLK/PLL1 (Pin 6) ---> GND SFOR1 (Pin 7) ---> VCC (3.3V off Arduino) MUTE (Pin 8) ---> GND DEEM/CLKOUT (Pin 9) ---> VCC (3.3V off Arduino) PLL0 (Pin 10) ---> GND SFOR0 (Pin 11) ---> VCC (3.3V off Arduino) VREF(DAC) (Pin 12) ---> 47uF capacitor to GND VDDA (Pin 13) ---> VCC (3.3V off Arduino) VOUTL (Pin 14) ---> Arduino Analog 0 VSSA (Pin 15) ---> GND VOUTR (Pin 16) ---> Unconnected

You do realize that device is not rated for 5V?

The datasheet says Max Vhi = 5.0V that does not mean you can use 5V I/O. It just means that the chip can survive 5.0V applied to an input. If you looked at any of your UNO's output pins, you may see 'ringing' on the leading and trailing edges of the signals. This ringing can exceed the 5V supply levels by up to 50%. This is dependent upon the actual capacitance and inductance of your wiring.

You need to insert some voltage level shifter between the Arduion and the DAC.

Check out CD4050 Hex buffers, Just power the CD4050 from your 3.3v, it's inputs can handle 5V+ and covert it down to the 3.3v levels.

Chuck.

Thanks for the advice. I thought that since the chip was rated tolerant for 5V input on certain pins that it would register those pins as logic high anyways. I tried what you said, only with a 74HC125 because I didn't have any 4050s on hand. I tested it out before trying it and was able to get 3.3V out of it just fine, but the DAC still doesn't work. Before this test, the output of the DAC was stuck on 1.6V always, but it seems that's not the case anymore, as the output of the DAC seems to be fluctuating every time I reset and re-monitor the arduino. I'm using the UNO and also a multimeter to verify the readings to make sure they're correct.

Thanks for the quick reply, hopefully this can get fixed real soon!

Judd

Judd: Thanks for the advice. I thought that since the chip was rated tolerant for 5V input on certain pins that it would register those pins as logic high anyways. I tried what you said, only with a 74HC125 because I didn't have any 4050s on hand. I tested it out before trying it and was able to get 3.3V out of it just fine, but the DAC still doesn't work. Before this test, the output of the DAC was stuck on 1.6V always, but it seems that's not the case anymore, as the output of the DAC seems to be fluctuating every time I reset and re-monitor the arduino. I'm using the UNO and also a multimeter to verify the readings to make sure they're correct.

Thanks for the quick reply, hopefully this can get fixed real soon!

Judd

the 1.6v is Vdd/2

Hopefully the 5V did not damage the IC.

I read a little of the DataSheet, it talks about rigid order of signal changes. Make sure you are toggling the control pins in the correct order.

Chuck.