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?