Pages: [1]   Go Down
Author Topic: SPI max size....  (Read 364 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18775
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
void send24bits (const unsigned long value)
  {
  SPI.transfer ((value >> 16) & 0xFF); 
  SPI.transfer  ((value >> 8) & 0xFF); 
  SPI.transfer  (value & 0xFF); 
  }  // end of send24bits
Logged


Pages: [1]   Go Up
Jump to: