Jump to content
Sign in to follow this  
gonya707

AD9850 Library (DDS function generator)

Recommended Posts

Hi there. First of all I'm not sure if I should post this here or inside another section fo the forum, apologies if I made a mistake.

 

WBJqMjS.jpg

 

Probably some of you already know this IC, the AD9850. Its a sine and square wave generator with output frequencies between 0Hz and...more than 60MHz! Due to its very low price (around $5 on eBay) and usefulness, it is definitively a module everybody should have if you can't afford a function generator. This library comes with several functions you might find useful:

/* Starts AD9850 operation changing its value to "all zeros".
 * Refreshes previous status from the microcontroller.*/
void AD9850_Init(void);
 
/* Reset operation for the AD9850. This function must be called before using AD9850_Osc
 * first time in the execution (check page 12 on datasheet)  */
void AD9850_Reset(void);
 
/* Sets the DDS sine and square oscillator to the detailed "frequency" and "phase" variables.
 * "frequency" will be turned into a 32 bit word, so the frequency will have a resolution of 0.0291 Hz
 * with a 125 MHz reference clock. "phase" will be a 5 bit word instead so the resolution is
 * 11.5 degrees, or pi/32 radians. */
void AD9850_Osc(double frequency, double phase);
 
/* Enables power down mode. This method is used for a quick "all outputs" disable.
 * The effect is the same as AD9850_Osc(0,0), but it takes less clock cycles */
void AD9850_PowerDown(void);
 
/* Performs a frequency sweep increased in "inc"Hz steps. The frequency order is from low to high
 * and resets to the lower frequency when maximum frequency is reached. */
 
void AD9850_Sweep_Up(double minFreq, double maxFreq, double inc, int cyclesPerDelay);
 
/* Performs a frequency sweep decreased in "inc"Hz steps. The frequency order is from high to low
 * and resets to the higher frequency when minimum frequency is reached. */
 
void AD9850_Sweep_Down(double minFreq, double maxFreq, double inc, int cyclesPerDelay);
 
/* Performs a frequency sweep increased in "inc"Hz steps. The frequency order is from low to high,
 * but it changes to from high to low when the maximum frequency is reached and so on. */
void AD9850_Sweep_Loop(double minFreq, double maxFreq, double inc, int cyclesPerDelay);

Inside your main code you only need to include the library and init the module:

//AD9850 config
SysCtlPeripheralEnable(PORT_ENABLE);
GPIOPinTypeGPIOOutput(PORT, W_CLK|FQ_UD|DATA|RESET);
AD9850_Init();
AD9850_Reset();

//frequency = 10000Hz, phase = 0 rad
AD9850_Osc(10000, 0);

And that's it. You can download the codes attached to this post. I hope you find them useful.

STELLARIS_AD9850.c

STELLARIS_AD9850.h

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...