gd_illeperuma:
Hi all,
I have a DAC , AD5686. It requires 8bit registry address and 16bit data send via SPI. (24 all together)http://www.analog.com/en/digital-to-analog-converters/da-converters/ad5686/products/product.html
How can I do this, since default SPI size is 8 ?
Please help. Thanks in advance.
Gayan
Data is clocked on the falling edge of SCLK. So you need to set the SPI mode accordingly.
The SYNC pin on the device seems to be the device select (i.e. the SS pin).
The command to be sent and which DAC it goes to is determined by the first byte. So, to send data to the part, you would do this (pseudo-code):
uint16_t dac_data = (whatever)
uint8_t high_byte = dac_command << 4;
uint8_t high_byte |= dac_address;
uint8_t mid_byte = dac_data << 8;
uint8_t low_byte = dac_data & 0xFF;
digitalWrite (sync_pin, LOW); // begin transfer
SPI.transfer (high_byte); // send command + DAC address
SPI.transfer (mid_byte); // send DAC value hi byte
SPI.transfer (low_byte); // send DAC value, lo byte
digitalWrite (sync_pin, HIGH); // end transfer
Make sense?