Does anyone have any code handy that will allow me to interface a MAX536 DAC to a BS2?· I would like to use this IC as I am trying to program it in an existing application.· I have enclosed the datasheet for it.· This comminicates via SPI.
Thanks in Advance
Comments
Update_DAC:
· outVal = adcVal & $0FFF······················ ' copy output value
· outVal.NIB3 = (channel << 2) | %0001········· ' setup channel and control bits
· LOW CS······································· ' activate DAC
· SHIFTOUT SO, SK, MSBFIRST, [noparse][[/noparse]outVal\16]······· ' shift the control + dac bits
· HIGH CS
· RETURN
This routine assumes the LDAC line is tied low (see Table 1 in the docs you reference)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
http://forums.parallax.com/showthread.php?p=553090
That tread also has code for the TI TLV5618A and a long discussion about how to decipher DAC data sheets.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thanks
Brian
' {$STAMP BS2}
' {$PBASIC 2.5}
'DAC TESTER
'Hardware Notes
'LDAC Must be tied low to make adc outputs update on rising edge of cs
'16 bit serial input
'first 2 bits Address, next 2 control, next 12 data
'TP Must be tied to Vdd
'Variable Declarations
adcVal VAR Word
outval VAR Word
channel VAR Nib
'Constant Declarations
adcval=4000
channel = %0001 'should load channel 1?
'IO Declarations
CS PIN 13 'Chip Select
SO PIN 14 'Serial Data
SK PIN 15 'Serial Clock
· Update_DAC:
· outVal = adcVal & $0FFF······················ ' copy output value
· outVal.NIB3 = (channel << 2) | %0001········· ' setup channel and control bits
· LOW CS······································· ' activate DAC
· SHIFTOUT SO, SK, MSBFIRST, [noparse][[/noparse]outVal\16]······· ' shift the control + dac bits
· HIGH CS
· RETURN