PIC18 LaurTec Library  3.0 Beta
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
AD9833.c File Reference
#include "AD9833.h"

Go to the source code of this file.

Functions

void write_data_AD9833 (unsigned int data)
 
unsigned int compose_AD9833_control_word (unsigned char function_type)
 
void initialize_AD9833 (unsigned char fmclk)
 
void set_frequency_AD9833 (unsigned long freq_value, unsigned char frequency_register)
 
void tuning_frequency_AD9833 (unsigned char tuning_step, unsigned char direction, unsigned char frequency_register)
 
void set_phase_AD9833 (unsigned short long phase_value, unsigned char phase_register)
 
void set_function_AD9833 (unsigned char function_type)
 

Variables

unsigned int K
 
unsigned int register_word
 
unsigned int tuning_freq
 

Function Documentation

unsigned int compose_AD9833_control_word ( unsigned char  function_type)

This function compose the configuration word to set AD9833 features

Parameters
function_typeis a type of function to activate
Returns
configuration word to activate the functionality required
Note
This is a private function, the user should not use it.

Definition at line 71 of file AD9833.c.

References register_word.

void initialize_AD9833 ( unsigned char  fmclk)

AD9833 Initialization. This function should be called before using the AD9833 RESET command, write 0 into register FREQ0,FREQ1,PHASE0 and PHASE1 Set sinusoidal waveform, FREQ0 and PHASEO out

Parameters
fmclkis a master frequency [0...25MHz]
Returns
void

Definition at line 154 of file AD9833.c.

References FREQUENCY0_OUT, K, PHASE0_OUT, REG0, REG1, register_word, RESET_AD9833, set_frequency_AD9833(), set_function_AD9833(), set_phase_AD9833(), SIN, tuning_freq, and write_data_AD9833().

void set_frequency_AD9833 ( unsigned long  freq_value,
unsigned char  frequency_register 
)

This function write the frequency value into FREQ0 or FREQ1 register

Parameters
freq_valueis a frequency [0...12500000Hz]
frequency_registeris the register to write 0,REG0–>REGISTER0 1,REG1–>REGISTER1
Returns
void

Definition at line 178 of file AD9833.c.

References compose_AD9833_control_word(), K, tuning_freq, and write_data_AD9833().

void set_function_AD9833 ( unsigned char  function_type)

This function activate features AD9833 waveform generator

Parameters
function_typeis the function to activate 1,SIN–>sinusoidal waveform 2,TRIANGLE–>triangular waveform 3,SQUARE–>square waveform 4,FREQUENCY0_OUT–>FREQ0 register is used in the phase accumulator 5,FREQUENCY1_OUT–>FREQ1 register is used in the phase accumulator 6,PHASE0_OUT–>PHASE0 register data is added to the output of the phase accumulator 7,PHASE1_OUT–>PHASE1 register data is added to the output of the phase accumulator 9,SLEEP_MODE–>DAC powered down and internal clock disabled 10,POWER_ON–>no power down
Returns
void

Definition at line 293 of file AD9833.c.

References compose_AD9833_control_word(), FREQUENCY0_OUT, FREQUENCY1_OUT, PHASE0_OUT, PHASE1_OUT, POWER_ON, SIN, SLEEP_MODE, SQUARE, TRIANGLE, and write_data_AD9833().

void set_phase_AD9833 ( unsigned short long  phase_value,
unsigned char  phase_register 
)

This function write the phase value into PHASE0 or PHASE1 register

Parameters
phase_valueis a phase [0...3600]
phase_registeris the register to write 0,REG0–>REGISTER0 1,REG1–>REGISTER1
Returns
void

Definition at line 264 of file AD9833.c.

References write_data_AD9833().

void tuning_frequency_AD9833 ( unsigned char  tuning_step,
unsigned char  direction,
unsigned char  frequency_register 
)

This function increases or decreases the LSB register frequency value of a step bit for a tuning frequency

Parameters
tuning_stepis a step bit [0...255]
directionis a direction of increases or decreases 0,DOWN–>decrease 1,UP –>increase
frequency_registeris the register to write 0,REG0–>REGISTER0 1,REG1–>REGISTER1
Returns
void

Definition at line 225 of file AD9833.c.

References compose_AD9833_control_word(), tuning_freq, and write_data_AD9833().

void write_data_AD9833 ( unsigned int  data)

This function write the data to the SPI bus

Parameters
datato write to the SPI bus
Returns
void
Note
This is a private function, the user should not use it. Change this function to other microcontroller

Definition at line 49 of file AD9833.c.

References FSYNC.

Variable Documentation

unsigned int K

Definition at line 41 of file AD9833.c.

unsigned int register_word

Definition at line 42 of file AD9833.c.

unsigned int tuning_freq

Definition at line 43 of file AD9833.c.