LTlib LaurTec Library  4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
AD9833.h File Reference
#include "LTlib.h"

Go to the source code of this file.

Macros

#define AD9833_SPI_MODULE_1
 
#define AD9833_SPI_open   SPI1_open
 
#define AD9833_SPI_baudrate   SPI1_baudrate
 
#define AD9833_SPI_mode   SPI1_mode
 
#define AD9833_SPI_write_byte   SPI1_write_byte
 
#define FSYNC   PORTAbits.RA5
 
#define FSYNC_DIRECTION   TRISAbits.TRISA5
 
#define AD9833_RESET   0b0000000100000000
 
#define AD9833_REG0   0
 
#define AD9833_REG1   1
 
#define AD9833_DOWN   0
 
#define AD9833_UP   1
 
#define AD9833_SIN   1
 
#define AD9833_TRIANGLE   2
 
#define AD9833_SQUARE   3
 
#define AD9833_FREQUENCY0_OUT   4
 
#define AD9833_FREQUENCY1_OUT   5
 
#define AD9833_PHASE0_OUT   6
 
#define AD9833_PHASE1_OUT   7
 
#define AD9833_SLEEP_MODE   9
 
#define AD9833_POWER_ON   10
 
#define write_data_AD9833   AD9833_write_data
 
#define compose_AD9833_control_word   AD9833_compose_control_word
 
#define initialize_AD9833   AD9833_initialize
 
#define set_frequency_AD9833   AD9833_set_frequency
 
#define tuning_frequency_AD9833   AD9833_tuning_frequency
 
#define set_phase_AD9833   AD9833_set_phase
 
#define set_function_AD9833   AD9833_set_function
 

Functions

void AD9833_write_data (unsigned int data)
 
unsigned int AD9833_compose_control_word (unsigned char function_type)
 
void AD9833_initialize (unsigned char fmclk)
 
void AD9833_set_frequency (unsigned long freq_value, unsigned char frequency_register)
 
void AD9833_tuning_frequency (unsigned char tuning_step, unsigned char direction, unsigned char frequency_register)
 
void AD9833_set_phase (unsigned long phase_value, unsigned char phase_register)
 
void AD9833_set_function (unsigned char function_type)
 

Macro Definition Documentation

#define AD9833_DOWN   0

Definition at line 117 of file AD9833.h.

#define AD9833_FREQUENCY0_OUT   4

Definition at line 122 of file AD9833.h.

#define AD9833_FREQUENCY1_OUT   5

Definition at line 123 of file AD9833.h.

#define AD9833_PHASE0_OUT   6

Definition at line 124 of file AD9833.h.

#define AD9833_PHASE1_OUT   7

Definition at line 125 of file AD9833.h.

#define AD9833_POWER_ON   10

Definition at line 127 of file AD9833.h.

#define AD9833_REG0   0

Definition at line 115 of file AD9833.h.

#define AD9833_REG1   1

Definition at line 116 of file AD9833.h.

#define AD9833_RESET   0b0000000100000000

Definition at line 114 of file AD9833.h.

#define AD9833_SIN   1

Definition at line 119 of file AD9833.h.

#define AD9833_SLEEP_MODE   9

Definition at line 126 of file AD9833.h.

#define AD9833_SPI_baudrate   SPI1_baudrate

Definition at line 77 of file AD9833.h.

#define AD9833_SPI_mode   SPI1_mode

Definition at line 78 of file AD9833.h.

#define AD9833_SPI_MODULE_1

Definition at line 72 of file AD9833.h.

#define AD9833_SPI_open   SPI1_open

Definition at line 76 of file AD9833.h.

#define AD9833_SPI_write_byte   SPI1_write_byte

Definition at line 79 of file AD9833.h.

#define AD9833_SQUARE   3

Definition at line 121 of file AD9833.h.

#define AD9833_TRIANGLE   2

Definition at line 120 of file AD9833.h.

#define AD9833_UP   1

Definition at line 118 of file AD9833.h.

#define compose_AD9833_control_word   AD9833_compose_control_word

Definition at line 158 of file AD9833.h.

#define FSYNC   PORTAbits.RA5

Definition at line 105 of file AD9833.h.

#define FSYNC_DIRECTION   TRISAbits.TRISA5

Definition at line 106 of file AD9833.h.

#define initialize_AD9833   AD9833_initialize

Definition at line 176 of file AD9833.h.

#define set_frequency_AD9833   AD9833_set_frequency

Definition at line 191 of file AD9833.h.

#define set_function_AD9833   AD9833_set_function

Definition at line 247 of file AD9833.h.

#define set_phase_AD9833   AD9833_set_phase

Definition at line 226 of file AD9833.h.

#define tuning_frequency_AD9833   AD9833_tuning_frequency

Definition at line 211 of file AD9833.h.

#define write_data_AD9833   AD9833_write_data

Definition at line 145 of file AD9833.h.

Function Documentation

unsigned int AD9833_compose_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 68 of file AD9833.c.

References register_word.

void AD9833_initialize ( 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 151 of file AD9833.c.

References AD9833_FREQUENCY0_OUT, AD9833_PHASE0_OUT, AD9833_REG0, AD9833_REG1, AD9833_RESET, AD9833_set_frequency(), AD9833_set_function(), AD9833_set_phase(), AD9833_SIN, AD9833_SPI_baudrate, AD9833_SPI_mode, AD9833_SPI_open, AD9833_write_data(), FSYNC_DIRECTION, K, PIN_AS_OUTPUT, register_word, SPI_CLK_OSC_64, SPI_MASTER_DEVICE, SPI_MODE_2, and tuning_freq.

void AD9833_set_frequency ( 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 181 of file AD9833.c.

References AD9833_compose_control_word(), AD9833_write_data(), K, and tuning_freq.

void AD9833_set_function ( 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 296 of file AD9833.c.

References AD9833_compose_control_word(), AD9833_FREQUENCY0_OUT, AD9833_FREQUENCY1_OUT, AD9833_PHASE0_OUT, AD9833_PHASE1_OUT, AD9833_POWER_ON, AD9833_SIN, AD9833_SLEEP_MODE, AD9833_SQUARE, AD9833_TRIANGLE, and AD9833_write_data().

void AD9833_set_phase ( unsigned 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 267 of file AD9833.c.

References AD9833_write_data().

void AD9833_tuning_frequency ( 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 228 of file AD9833.c.

References AD9833_compose_control_word(), AD9833_write_data(), and tuning_freq.

void AD9833_write_data ( 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 fit other microcontroller models.

Definition at line 49 of file AD9833.c.

References AD9833_SPI_write_byte, and FSYNC.