Go Down

Topic: SPI max size.... (Read 592 times) previous topic - next topic


If I wanted to transfer 12 bit data on the arduino, would I have to separate the string into two strings or can I simply do SPI.transfer(4095)?  I am working with a dual DAC that takes a 24 bit read (the first 12 is the first DAC, the second is the 2nd DAC). I am kind of confused and hoping that i do not have to separate it into three strings for the full 24 bit write.

Nick Gammon

Just do 3 x SPI.transfer. That will be 24 bits. You will of course have to split up the 24-bit field.

Something along these lines:

Code: [Select]

void send24bits (const unsigned long value)
  SPI.transfer ((value >> 16) & 0xFF); 
  SPI.transfer  ((value >> 8) & 0xFF); 
  SPI.transfer  (value & 0xFF); 
  }  // end of send24bits
Please post technical questions on the forum, not by personal message. Thanks!

More info:

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131