Hello,
I'm using a TLV5616 12-bit DAC, and controlling it via SPI from an Atmel 8-bit AVR processor (AT90USB1286) (A Teensy 2.0++):
I'm controlling the /CS and FS lines from software. Only SCLK and MOSI are controlled automatically via the chip's SPI module. Currently, it is working, and I am seeing the expected DAC output, however, in order to change it, I need to send the data twice. Any ideas why?
First, I'm not positive as to which SCLK settings to use. There are two options: one for SCLK Polarity, and SCLK Phase. Since the TLV5616 datasheet says data are clocked in on the falling edge of SCLK, I have my SCLK polarity set to inverted (CPOL=1). Phase is normal (CPHA=0). Does this sound correct? The Atmel datasheet refers to these 4 combinations as Mode 0, Mode 1, etc. and I have it configured in Mode 1. In other words, which SPI mode does this DAC expect SPI data?
Second, (this may be related), does anyone have any idea why I would have to send my data twice to the DAC, in order to get it to update? I have an LED blink to verify the data is being sent, and I see my CS and FS lines go low. The datasheet says the DAC should update After the 16th bit is sent, or FS goes high. Here is my code (just testing one DAC, although two are part of the design).
PORTB &= ~(1<<PB4); // /CS on DACA low
PORTB &= ~(1<<PB0); // FS Low
// Send Data MSB (bit and byte) First. SPI_MasterSend( (SPD_CTRL<<6) | (val_high & 0x0F) ); // Byte 0 SPI_MasterSend( val_low ); // Byte 1
PORTB |= (1<<PB0); // FS High PORTB |= (1<<PB4)|(1<<PB5); // Both /CS High
I've tried just about everything, to no avail: Adding delays between all signal line transitions, Slower SCLK, All combinations of CPOL and CPHA, and even eliminated /CS, by tying it to ground. Any suggestions?
Thank you very much,
Jonathon Reinhart