I have an AD5685R DAC that I am trying to communicate with over SPI. Per the datasheet,

...These [24] bits are transferred to the input register on the 24 falling edges of SCLK and are updated on the rising edge of /SYNC

where /SYNC is used as chip-select.

I believe Arduino's SPI.transfer waits to receive 8 bits after sending 8 bits. But for this particular DAC, I need to send 24 straight bits on 24 clock edges before releasing the chip-select. Is this possible?

4 Answers 4


I believe Arduino's SPI.transfer waits to receive 8 bits after sending 8 bits.

Incorrect. With SPI, a byte is clocked in at the same time as a byte is clocked out. It may be that this byte is simply a dummy byte though, if the slave has nothing to say.

So for 24 bits, simply clock out 3 bytes without deasserting the select. Since SPI is a synchronous protocol there should be no issue with having a delay in between bytes provided the select is maintained.


In the SPI protocol, you get one byte back for every one you send. If you are not interested in the response from a device, you can just ignore the return bytes.

SPI has no handshaking. You just must send no faster than the slave device can handle. In the case of the AD5685R, that is 50 MHz.

For multibyte transfer, you keep the chip select asserted (low) between every byte by setting the transferMode to SPI_CONTINUE in the SPI.transfer call. For the last byte, you will deassert the chip select (set it high) by setting the transferMode parameter to SPI_LAST in the SPI.transfer call..

  • 1
    Unless you have one of those weird SPI devices with a positive select. Commented Nov 20, 2014 at 18:30

Note that there is also a version of SPI.transfer for multi-byte (buffer) transfers:

SPI.transfer(buffer, size)

I used the buffer transfer in my library for the TLC59711 (see code) and found the buffer transfer faster than transferring bytes individually using SPI.transfer(val); the switch to buffer transfers is one of the reasons my library is about 3.5 times faster than a previous library for the TLC59711.

  • This is relatively new, works in Arduino 1.8, not sure about 1.0.
    – qwr
    Commented Jan 14, 2019 at 18:21

Looks like it just set cs low and do three byte transfers then bring it high. Here's someone's example on how to do it:


Code below taken from above page.

#include <SPI.h> 

const int csPin = 10;

void setup() {

 SPI.setBitOrder(MSBFIRST); //We know this from the Data Sheet

 digitalWrite(csPin, HIGH);

void loop() {
 for(int i=0; i<1023; i++) { 

void digitalPotWrite(int address, int value) {
 digitalWrite(csPin, LOW); //select slave
 byte command = 0xB0; //0xB0 = 10110000 
 command += address; 
 byte byte1 = (value >> 8);
 byte byte0 = (value & 0xFF); //0xFF = B11111111
 digitalWrite(csPin, HIGH); //de-select slave

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.