DAC81408 cant get any output

Status
Not open for further replies.

mah

Well-known member
Hey, my and my friend is trying to get the TI DAC81408 to work on our custom board, we think we got the code right, but cant seem to get any output from the dac.
we are both kinda new trying to implement Spi devices from a datasheet, so i am hoping we made something wrong in the code rather than the hardware :)
https://www.ti.com/product/DAC81408
I have noticed when checking my oscilloscope that the dac forwards the data we send it (with some alterations) to its SDO output (i think this is because of the daisy chain feature) but that makes me hopeful that at least the DAC is "alive"
here is the schematic: dac.jpg

Code:
/*
DATA SHEET
https://www.ti.com/lit/ds/symlink/dac81408.pdf?ts=1615149239532&ref_url=https%253A%252F%252Fwww.ti.com%252Fstore%252Fti%252Fen%252Fp%252Fproduct%252F%253Fp%253DDAC81408RHAR
*/

#include <SPI.h>

//CHIP SELECT
const int CSdac = 36 ;
const int CSadc = 10;
const int CSdigiexp = 37;
//resett and clear
const int clr = 30;
const int rst = 31;
//                   speed   bitorder  edge_mode
SPISettings DACx1408(100000, MSBFIRST, SPI_MODE1);

void setup()
{
    pinMode(CSdac, OUTPUT);
    pinMode(rst, OUTPUT);
    pinMode(CSadc, OUTPUT);
    pinMode(CSdigiexp, OUTPUT);
    pinMode(clr, OUTPUT);
//     just in case!
    digitalWrite(rst, HIGH);
    digitalWrite(clr, HIGH);
    digitalWrite(CSadc, HIGH);
    digitalWrite(CSdigiexp, HIGH);

    SPI.begin();
    delay(100);

}

void loop()
{
    // | byte |  | byte |    |     byte   |
    // |      data      |    adress     RW
    // ........  ........    ......  x   .
     
    // MSB first
    // |   byte  |  |  byte ||  byte |
    // RW  adress   |      data      |    
    // . x  .....   ........  ........
    //
    //vMin to vMax, decmial 0 to 65536

    for (int ch = 0; ch < 7; ch++)
    {
        SPI.beginTransaction(DACx1408);
        //ASSERT CHIP SELECT LOW
        digitalWrite(CSdac, LOW);
        SPI.transfer(20 + ch);
        SPI.transfer(0);
        SPI.transfer(0);
        //DE-ASSERT CHIP SELECT HIGH
        digitalWrite(CSdac, HIGH);
        SPI.endTransaction();
        delay(100);
    }

    delay(500);

    for (int ch = 0; ch < 7; ch++)
    {
        SPI.beginTransaction(DACx1408);
        //ASSERT CHIP SELECT LOW
        digitalWrite(CSdac, LOW);
        SPI.transfer(20 + ch);
        SPI.transfer(255);
        SPI.transfer(255);
        //DE-ASSERT CHIP SELECT HIGH
        digitalWrite(CSdac, HIGH);
        SPI.endTransaction();
        delay(100);
    }
    delay(500);
}
 
haha never mind, we forgot to turn on the interna ref, and enebling the dac etc.

Working fine now!
 
just got it working, but just for fun i made it output sqaurewaves (on all 8 channels) and i measured them at 2.7kHz using delaymicroseconds(1)

probably much faster if you know how to code ;), it supports spi clocks up to 50Mhz
 
Last edited:
Status
Not open for further replies.
Back
Top