Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing with an LTC1451 — Parallax Forums

Interfacing with an LTC1451

tdeyletdeyle Posts: 85
edited 2009-01-15 00:15 in Propeller 1
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[noparse][[/noparse]CS]  := 1                                      'Make  CS  pin an output
    dira[noparse][[/noparse]SDI] := 1                                      'Make  SDI pin an output
    dira[noparse][[/noparse]CLK] := 1                                      'Make  CLK pin an output

    outa[noparse][[/noparse]CS]  := 0                                      'Bring CS low                     
    outa[noparse][[/noparse]CLK] := 0                                      'Bring CLK low ; load AD8803 data
    
    SendData(SDI,CLK,12,DACvalue)                        'Select Value
    
    outa[noparse][[/noparse]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[noparse][[/noparse]SDI] := (Data & temp)/temp                   'Set bit value
      outa[noparse][[/noparse]CLK] := 1                                    'Clock bit
      outa[noparse][[/noparse]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?

Comments

  • tdeyletdeyle Posts: 85
    edited 2009-01-14 22:53
    Duh, the variable's a byte.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2009-01-14 22:55
    tdeyle,

    You need to re-define DACvalue as a word

    This section of code ...
    VAR 
       byte DACaddress,DACvalue
    

    ...should read

    VAR 
       word DACvalue
    

    Note: You can·remove DACaddress since you don't use it in your case.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2009-01-14 22:55
    Yoy beat me to it! smilewinkgrin.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • tdeyletdeyle Posts: 85
    edited 2009-01-15 00:15
    Ya, the last few posts where I have posted questions, I ended up figuring them out afterwards!

    I think I was more caught up in figuring out how to communicate with the DAC (I am not too good with serial communications), that I overlooked that bit!
Sign In or Register to comment.