tdeyle
01-15-2009, 05:02 AM
Ok, I am trying to interface with the LTC1451 12 bit DAC. I am using a modified version of the AD8803 code from the OBEX.
The only code that was changed was the demo code, AD8803_Demo, to cycle from values of 0 to 4096, and the AD8803.spin code, where I have replaced the bit size with 12 instead of 8. I have also removed the DACaddress variable, since the LTC1451 is a single DAC, not an octal.
Here is a copy of the Demo code, and below that is the modified AD8803.spin code:
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
CS = 3
SDI = 2
CLK = 1
OBJ
DAC: "LT1451"
VAR
byte DACaddress,DACvalue
PUB Demo | x
repeat
repeat x from 1 to 4096
DACvalue := x
DAC.Set(CS,SDI,CLK,DACvalue)
waitcnt(clkfreq/100+cnt)
PUB Set(CS,SDI,CLK,DACvalue)
dira[CS] := 1 'Make CS pin an output
dira[SDI] := 1 'Make SDI pin an output
dira[CLK] := 1 'Make CLK pin an output
outa[CS] := 0 'Bring CS low
outa[CLK] := 0 'Bring CLK low ; load AD8803 data
SendData(SDI,CLK,12,DACvalue) 'Select Value
outa[CS] := 1 'Bring CS high ; latch AD8803 data
PRI SendData(SDI,CLK,Bits,Data)|temp 'Send DATA MSB first
temp := 1 << ( Bits - 1 )
repeat Bits
outa[SDI] := (Data & temp)/temp 'Set bit value
outa[CLK] := 1 'Clock bit
outa[CLK] := 0 'Clock bit
temp := temp / 2
I connected a scope to the CLK, CS, and SDI inputs, and noted that the Prop counts up to the 8th bit, then restarts the cycle. It does not go to the 12th bit.
I am wondering, since it looks as though the AD8803.spin code is independent to the bit width, why it would do this?
The only code that was changed was the demo code, AD8803_Demo, to cycle from values of 0 to 4096, and the AD8803.spin code, where I have replaced the bit size with 12 instead of 8. I have also removed the DACaddress variable, since the LTC1451 is a single DAC, not an octal.
Here is a copy of the Demo code, and below that is the modified AD8803.spin code:
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
CS = 3
SDI = 2
CLK = 1
OBJ
DAC: "LT1451"
VAR
byte DACaddress,DACvalue
PUB Demo | x
repeat
repeat x from 1 to 4096
DACvalue := x
DAC.Set(CS,SDI,CLK,DACvalue)
waitcnt(clkfreq/100+cnt)
PUB Set(CS,SDI,CLK,DACvalue)
dira[CS] := 1 'Make CS pin an output
dira[SDI] := 1 'Make SDI pin an output
dira[CLK] := 1 'Make CLK pin an output
outa[CS] := 0 'Bring CS low
outa[CLK] := 0 'Bring CLK low ; load AD8803 data
SendData(SDI,CLK,12,DACvalue) 'Select Value
outa[CS] := 1 'Bring CS high ; latch AD8803 data
PRI SendData(SDI,CLK,Bits,Data)|temp 'Send DATA MSB first
temp := 1 << ( Bits - 1 )
repeat Bits
outa[SDI] := (Data & temp)/temp 'Set bit value
outa[CLK] := 1 'Clock bit
outa[CLK] := 0 'Clock bit
temp := temp / 2
I connected a scope to the CLK, CS, and SDI inputs, and noted that the Prop counts up to the 8th bit, then restarts the cycle. It does not go to the 12th bit.
I am wondering, since it looks as though the AD8803.spin code is independent to the bit width, why it would do this?