This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DAC1220: Interfacing DAC1220 with Teensy 3.5 (MCU with 3.3V supply rails)

Part Number: DAC1220

Hi TI team,

I am trying to interface DAC1220 from TI with Teensy 3.5 (Arduino compatible development board) Teensy supply rails are 3.3V, but pins are 5V tolerant. DAC1220 is powered with 5V (both AVDD and DVDD are 5V). My issue is I cannot get teens talk to DAC1220. Whatever I set in the code, the DAC1220 output stays at around reference voltage, 2.5V. 

I checked the DAC1220 logic input level. DAC1220 requires min 2V input high voltage. Output high voltage of teensy (min) is around 2.7V - 2.8V.  Teensy input high voltage requires at least 2.1-2.2V, this is also ok with DAC1220 specifications.

I tried my code with Arduino that has 5V supplies, It worked I was able to control the DAC and set the voltage I want. 

My question is why the DAC is performs ok with 5V MCU, but not works with 3.3V MCU (logic levels meets the specs) ?

#define PIN_CS  20//enable
#define PIN_CLK  37//spi clock
#define PIN_DAT 38//spi data

uint32_t Millis = 0;
uint8_t  Buf[10];
uint8_t  Len = 0;
float cal = 1.00015; 
float offset = 0.0004; 
float voltageLimit = 4.99; 
float v=3.58; // DAC out voltage
void setup() {
  Serial.begin(9600);
  pinMode(PIN_CS, OUTPUT);
  pinMode(PIN_CLK, OUTPUT);
  pinMode(PIN_DAT, OUTPUT);
  pinMode(13, OUTPUT);
  digitalWrite(PIN_CS, HIGH);
    digitalWrite(13, HIGH);

  reset();
}

void loop() {
  sendData(v);
delay(1000);
  }


void sendData (float setVoltage) {
  if (setVoltage < offset) {
    setVoltage = offset;
  }
  else if (setVoltage > voltageLimit) {
    setVoltage = voltageLimit;
  }
  uint32_t bitCode = voltageToBits(setVoltage * cal - offset);
  if (bitCode > 0xFFFFF) {
    bitCode = 0xFFFFF;
    Serial.println("input value clipped.");
  }
  Serial.print("Voltage: ");
  Serial.print(setVoltage, 4);
  Serial.print("  Bits: ");
  Serial.println(bitCode);
  Serial.println("-----------------------");
  Serial.println("");
  bitCode = bitCode << 4;

  digitalWrite(13, HIGH);
  digitalWrite(PIN_CS, LOW);
  shiftOut(PIN_DAT, PIN_CLK, MSBFIRST, 0x40);
  shiftOut(PIN_DAT, PIN_CLK, MSBFIRST, (bitCode & 0x00FF0000) >> 16);
  shiftOut(PIN_DAT, PIN_CLK, MSBFIRST, (bitCode & 0x0000FF00) >> 8);
  shiftOut(PIN_DAT, PIN_CLK, MSBFIRST, (bitCode & 0x000000FF));
  digitalWrite(PIN_CS, HIGH);
  digitalWrite(13, LOW);
}

uint32_t voltageToBits(float voltage) {
  return (voltage / 5.0) * pow(2, 20);
}

void reset () {
  digitalWrite(13, HIGH);
  digitalWrite(PIN_CS, LOW);
  //Reset DAC
  pinMode(PIN_CLK, OUTPUT);
  digitalWrite(PIN_CLK, LOW);
  delay(1);
  digitalWrite(PIN_CLK, HIGH);
  delayMicroseconds(240); //First high period (600 clocks)
  digitalWrite(PIN_CLK, LOW);
  delayMicroseconds(5);
  digitalWrite(PIN_CLK, HIGH);
  delayMicroseconds(480); //Second high period (1200 clocks)
  digitalWrite(PIN_CLK, LOW);
  delayMicroseconds(5);
  digitalWrite(PIN_CLK, HIGH);
  delayMicroseconds(960); //Second high period (2400 clocks)
  digitalWrite(PIN_CLK, LOW);
  delay(1);
  //Start Self-Calibration
  shiftOut(PIN_DAT, PIN_CLK, MSBFIRST, 0x05);
  //20-bit resolution
  shiftOut(PIN_DAT, PIN_CLK, MSBFIRST, 0xA1); //20-bit resolution
  digitalWrite(PIN_CS, HIGH);
  delay(600);
  digitalWrite(13, LOW);
  Serial.println("DAC reset sucessful");
  sendData(2.5);
}

void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, int val, uint8_t bits = 8, uint8_t del = 10) {
  uint8_t i;
  for (i = 0; i < bits; i++)  {
    if (bitOrder == LSBFIRST)
      digitalWrite(dataPin, !!(val & (1 << i)));
    else
      digitalWrite(dataPin, !!(val & (1 << ((bits - 1 - i)))));
    digitalWrite(clockPin, HIGH);
    delayMicroseconds(del);
    digitalWrite(clockPin, LOW);
  }
}

Thank you for your help.

  • Hi Ahmet,

    Are you connecting the two devices with wires, or are they on the same board?  I have seen that if your wiring is non-ideal you will need to high logic levels as the attenuation is too great.  If you look at the logic with an oscilloscope, are they clean?

    Thanks,

    Paul

  • Hi Paul,

    I am sorry for late reply. I was not at the laboratory.

    I tried both version. The microcontroller (teensy board) is DIP package. I mounted teensy on breadboard and used wires to make interface with DAC1220 (it was on different pcb). The out was 2.456V. I also mounted teensy on the PCB, both dac1220 and teensy were on same board and the interface lines were the tracks on the PCB. The out was 2.459V.

    I guess the problem most probably is not with the voltage levels. Because I tested the DAC1220 with 3.3V voltage level mcu (Arduino). Although the wires were used to make interface with DAC, I was able to adjust output to whatever I want. The code I am using I guess works with 3.3V arduino, but does not work with Arduino compatible teensy. Is this correct assumption?

    I will check with oscilloscope and let you know. 

    Thank you for the help,

    Ahmet

  • Hi,

    Did you check with oscilloscope? Please let us know if you need more help.

    Regards.

    AK

  • Hi Akhilesh, 

    I guess I found the reason. The problem was related to software, not to hardware. I was able to solve the problem. The teensy was executing some functions very fast.

    Thank you all for the help,

    Ahmet