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.

TLV5616: Communicating with SPI DAC

Part Number: TLV5616

I'm trying to interface the TLV5616 with an mbed via SPI.

The connections I've made are as follows:

https://i.stack.imgur.com/duiLJ.png

Note: mbed is powered from same 5V supply.


I modified the mbed SPI helloworld prorgam:

#include "mbed.h"

SPI spi(p5, p6, p7); // mosi, miso, sclk
DigitalOut cs(p8);


int main() {

uint16_t fixed = 0x4000;
uint16_t value = 1000;

uint16_t final = value << 2;
final = fixed ^ value;
cs = 1;


spi.format(16,3);
spi.frequency(1000000);


// Select the device by seting chip select low
cs = 0;

// Send 0x8f, the command to read the WHOAMI register
spi.write(final);

// Deselect the device
cs = 1;


}

The first 4 bits (from the left) should be 0100, and the last 2 bit, 00. The 10-bit value goes in between. This is explained in the datasheet (www.tij.co.jp/.../tlv5616.pdf).

I've used the bit pattern 0x4000, and XOR'd it with the 10-bit value, which is shifted by two. This should result in a bit pattern accepted by the DAC.

However, when measuring the DAC output, the value tends to stay around 200mv, sometimes going under, which leads me to believe something is not quite working. With a value of 1000, you would expect a value closer to 3.3v (REF).

I should mention that I haven't used a capacitor in this circuit, although I don't think it's necessary to test the basic functionality.

Any thoughts on what's going wrong?

  • Hi EE,

    I think you are using the wrong SPI mode. A quick google of Mbed shows that spi.format mode 3 means PHA = 1 and POL = 1. I believe for this device you want to use mode 1 or 2 instead. Give those a try and let us know if that works.

    Thanks!
    Paul
  • Hi Paul,

    I suspected that may be the problem, so I tried all modes. Sadly, none worked...

    EE

  • I've updated the code to generate a pulse before data is sent (FS line). Still no luck:

    #include "mbed.h"
     
    SPI spi(p5, p6, p7); // mosi, miso, sclk
    DigitalOut fs(p8);
    
     
    int main() {
        // Chip must be deselected
        uint16_t fixed = 0x4000;
        uint16_t value = 1024;
        
        uint16_t final = value << 2;
        final = fixed ^ value;
        fs = 1;
    
        // Setup the spi for 8 bit data, high steady state clock,
        // second edge capture, with a 1MHz clock rate
        spi.format(16,1);
        spi.frequency(1000000);
     
     
        
        
        fs = 0;
        fs = 1;
        wait(1);
        fs = 0;
     
        
        spi.write(final);
        
        wait(1);
        
        fs = 1;
        
        
    }

  • Hi EE,

    Have you been able to confirm with a scope or logic analyzer that your SPI frame looks correct? Can you confirm the VDD and VREF voltages as well? What circuitry is on the output of the DAC?

    Thanks!
    Paul
  • I don't have a scope, so hard to know. I've just checked, and VREF is indeed 3.3v. However, VDD seems to be ~12, so my 5V supply must be faulty.
    Is this what's most likely causing the issue? And will I need to replace the chip?

    Cheers.
  • A few other things I'd like to confirm:

    1) Before transmission, should I bring FS high (from low), and then low again?
    2) After transmission, do I need to bring FS high and low again?

    Cheers.
  • The data is latched with the low to high transition of the FS. FS may remain high after the communication packet and be asserted low only when a new SPI command is beginning.

    It is possible you damaged the device by supplying 12V to it, as that exceeds the absolute maximum supply ratings. I suspect you have an issue with your regulator circuit. You might try remedying the supply issue and then replace the DAC to confirm.

    Thanks!
    Paul
  • Ok, so I've replaced the chip, and obtained a new 5v, and 3.3v supply, which I can confirm works.

    The code is now as follows:

    Code (Text):
    1. #include "mbed.h"
    2. SPI spi(p5, p6, p7); // mosi, miso, sclk
    3. DigitalOut fs(p8);
    4.  
    5. int main() {
    6.     fs = 0;
    7.  
    8.     uint16_t fixed = 0x4000;
    9.     uint16_t value = 1024;
    10.  
    11.     uint16_t final = value << 2;
    12.     final = fixed ^ value;
    13.  
    14.  
    15.     spi.format(16,2);
    16.     spi.frequency(1000000);
    17.     wait(1);
    18.     fs = 1;
    19.     wait(1);
    20.     fs = 0;
    21.     spi.write(final);
    22.  
    23.     wait(1);
    24.  
    25.     fs = 1;
    26.  
    27.  
    28. }

    At first, OUT, as measured by the voltmeter is around 9mv (usually -9mv). After between 5 and 20 seconds (approx), the voltage spikes to around 1.6v, and once 3.3v.

    Can you explain this delay, and the inaccuracy?

  • Hi EE,

    I think it would be wise to look at the SPI packet with a scope or digital logic analyzer. It is difficult to tell the behavior of the device in this condition.