Skip to content

Instantly share code, notes, and snippets.

@MitchRatquest
Created September 9, 2016 03:18
Show Gist options
  • Save MitchRatquest/9d11d1ac9a5809a30c2a80d9193fd542 to your computer and use it in GitHub Desktop.
Save MitchRatquest/9d11d1ac9a5809a30c2a80d9193fd542 to your computer and use it in GitHub Desktop.
LTC1257 untested quick code
/*
shift register simpletown for LTC1257
12 bit DAC, 5V, 1.4MHz max clock
DIN, CLK, !LOAD
________
CLK - - VCC
DIN - - VOUT
!LOAD - - REF
DOUT -________- GND
DIN loaded into shift reg on rising edge of clock
MSB first
DAC loads data when !LOAD pulled low, then sets when !LOAD high
internal 5v reg, full rail swing: GND to VCC
can daisy chain them, DOUT to DIN, max 1.4MHz
*/
#define DIN 10
#define CLK 11
#define LOAD 12
void sendDAC(int data) //12 bits, 4095, 0xFFF
{
digitalWrite(LOAD, HIGH);
digitalWrite(CLK, LOW);
for(int i = 11; i >= 0; i++)
{
digitalWrite(DIN, data >> i & 1);
digitalWrite(CLK, HIGH);
digitalWrite(CLK, LOW);
}
digitalWrite(LOAD, LOW); // might want to set high after
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment