Go Down

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

Gibson486

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:
http://www.gammon.com.au/electronics

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!

Arduino
via Egeo 16
Torino, 10131
Italy