Shop OBEX P1 Docs P2 Docs Learn Events
Help with programming AD9833 wave-form generator chip — Parallax Forums

Help with programming AD9833 wave-form generator chip

BasicStampGuyBasicStampGuy Posts: 4
edited 2013-06-11 04:41 in BASIC Stamp
Hello All:
This is my first topic I post on Parallax.· I am trying to program an AD9833 waveform generator chip from Analog Devices using a BS2sx microcontroller and development board.· The AD9833 is operated by using Direct Digital Synthesis Technology (DDS) and is programmed using Serial Peripheral Interfacing (SPI).· The AD9833 chip requires word size variables to control the internal DDS circuitry.· It requires a control register - (to initialize the commands and to prepare the device to receive incomming streams of word data), Two 28 bit Frequency registers (You can select one of two frequency registers to write to, and send word size variables to fill in the 28 bit registry - to achieve this you can write two consecutive 16-bit words to the selected register, the first two MSB of the word contain the information to which frequency register the data will be written to and the remaining 14 bits are used to be written into the frequency register, doing this 2 consecutive times will fill in the 28-bit selected frequency register).· I was wondering if anybody out there has prototyped with the AD9833 chip using the Basic Stamp, or maybe they can give me some tips or ideas.· I have tried programming it, and pretty much understand how it is suppose to function and how to program it, but can't get anything out of it.· I don't know exactly how to check to see if it works.· Any help will be greatly appreciated.· Thanks for looking!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-04 00:24
    You will need to post a schematic of your setup and a copy of the program you've tried. It's hard to give advice without that much information, particularly if your setup doesn't seem to work at all.
  • BasicStampGuyBasicStampGuy Posts: 4
    edited 2008-04-04 00:48
    Thanks Mike:

    I will upload the schematic and the code soon.· Have you prototyped with the AD9833?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-04 01:54
    I've not used this chip before, but you may be hung up on something more basic.· First you get the Stamp to talk to the DDS chip, then worry about whether the conversation is meaningful.
    ·
  • BasicStampGuyBasicStampGuy Posts: 4
    edited 2008-04-04 02:31
    Here's a code that I came up with:

    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}

    SData PIN 4 'Serial data transfer channel
    SCLK PIN 5· 'Clock Channel
    FSYNC PIN 6 'FSYNC channel

    OUTPUT SData· 'Set variables as outputs on the proto-board
    OUTPUT SCLK
    OUTPUT FSYNC


    'Declare the word variables
    ControlReg VAR Word 'ControlReg is used to initialize the DDS circuitry
    FREQ0L VAR Word···· 'FREQ0L is the 14 LSB of the FREQ0 register
    FREQ0M VAR Word···· 'FREQ0M is the 14 MSB of the FREQ0 register
    FREQ1L VAR Word···· 'FREQ1L is the 14 LSB of the FREQ1 register
    FREQ1M VAR Word···· 'FREQ1M is the 14 MSB of the FREQ1 register
    PHASE0 VAR Word···· 'PHASE0 and PHASE 1 registers, these can be written to if you set the first two bits of the control register to '11'
    PHASE1 VAR Word
    Contr_term VAR Word

    'Give the variables a value
    ControlReg = $2000· 'Initialize DDS circuitry,make the frequency register operate as two 14-bit registers,Set the reset bit high
    FREQ00 = $4000····· 'Set the Control bits to write the the FREQ0 Register, and write first 14-bits of data
    FREQ01 = $403F····· 'Send another word to send the remaining 14-bits of data to the FREQ0 Register
    FREQ10 = $8000····· 'Select the FREQ1 Register and send all zeros
    FREQ11 = $8000····· 'Select the FREQ1 Register and send all zeros
    PHASE0 = $C000····· 'Select the PHASE0 Register and send nothing
    PHASE1 = $E000····· 'Select the PHASE1 Register and send nothing
    ConTerm = $0200···· 'Send a concluding word variable to set the register to 0


    'Set FSYNC low, send data, and set FSYNC high to end transmission
    LOW FSYNC
    SHIFTOUT SData,SCLK,LSBFIRST,[noparse][[/noparse]ControlReg,FREQ00,FREQ01,FREQ10,FREQ11,PHASE0,PHASE1,Contterm]
    HIGH FSYNC





    The code might not be correct, I might be missing something or, I may not be commanding the chip correctly or I may have small glitches (maybe I need a small pause somewhere), or who knows.



    I may even have the chip incorrectly set-up (I tied the analog and digital grounds together, I'm not sure if this is ok).· I have attached a schematic and a functional block diagram.· I'm going to keep trying and see if it works.· Thanks for looking, any comments are appreciated, thanks again.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2008-04-04 03:51
    Here are some previous threads I had bookmarked on commanding the ADS98xx DDS chips with the BASIC Stamp.

    http://forums.parallax.com/showthread.php?p=549662
    http://forums.parallax.com/showthread.php?p=561943


    groups.yahoo.com/group/basicstamps/message/44347
    groups.yahoo.com/group/basicstamps/message/35802
    groups.yahoo.com/group/basicstamps/message/35256
    The above yahoo groups threads are also archived here on the forum, if you back up to the top level ****Top of the Forum***** and then look at the bottom of the screen for the link to the archives.

    With respect to your code, the SHIFTOUT command defaults to 8 bit bytes. If you want to transmit other widths, as you certainly do here, the syntax requires a backslash...

    For example, [noparse][[/noparse]ControlReg\16,FREQ00\14,FREQ01\14, and so on. And the 14 least significant bits of the word variables would be sent.

    The variable names in the code you posted are not consistent with the declarations, so it would give a syntax error when compiled. But the main thing is getting the bits correct in the SHIFTOUT.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • BasicStampGuyBasicStampGuy Posts: 4
    edited 2008-04-04 16:40
    Thanks you guys I really appreciate the help!· If anybody else has advice or suggestions please post them.· Thanks again!
  • dewdew Posts: 1
    edited 2013-06-11 04:41
    I too need help in coding AD9833 ..I am trying to interface this chip with MSP430FG4618 micro-controller...
    How to proceed?...If someone can help me with the sample code/instructions/ examples....etc.please let me know as soon as possible..
    Thank you :)
Sign In or Register to comment.