PIC18 LaurTec Library
3.3.1
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
AD9833.h
Go to the documentation of this file.
1
/*******************************************************************************
2
3
Author : Dario Di Turi
4
Version : 1.2
5
Date : 08/12/2012
6
7
Last Update: Mauro Laurenti
8
Last Update: 15/12/2014
9
10
********************************************************
11
SOFTWARE LICENSE AGREEMENT
12
********************************************************
13
14
The usage of the supplied software imply the acceptance of the following license.
15
16
The software supplied herewith by Dario Di Turi (the Author) is intended for
17
use solely and exclusively on Microchip PIC Microcontroller (registered mark).
18
The software is owned by the Author, and is protected under applicable
19
copyright laws. All rights are reserved.
20
Any use in violation of the foregoing restrictions may subject the
21
user to criminal sanctions under applicable laws, as well as to civil liability
22
for the breach of the terms and conditions of this license.
23
Commercial use is forbidden without a written acknowledgement with the Author.
24
Personal or educational use is allowed if the application containing the
25
following software doesn't aim to commercial use or monetary earning of any kind.
26
27
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
28
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
29
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
30
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE AUTHOR SHALL NOT,
31
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
32
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
33
34
35
********************************************************
36
PURPOSES
37
********************************************************
38
39
This library contains all functions needed to control the DDS waveform generator
40
AD9833. Information on the AD9833 can be found on the website
41
Analog Devices www.analog.com
42
43
More details and pictures can be downloaded from www.LaurTec.com
44
45
*******************************************************************************/
46
47
48
#ifndef AD9833_H
49
#define AD9833_H
50
51
#ifdef __XC8
52
#include <xc.h>
53
#endif
54
55
#include <spi.h>
56
57
//**************************************************
58
// PIN CONNECTIONS
59
// Use the default pin to SPI connection
60
// SDATA(SDO) to RC7
61
// SCLK(SCK) to RB1
62
// FSYNC(SS) to RA5
63
//
64
// Remember:
65
// 1) The pull up resistor
66
// 2) Set the TRISx register
67
//**************************************************
68
69
#define FSYNC LATAbits.LATA5
70
71
72
//**************************************************
73
// COSTANTS
74
//**************************************************
75
76
#define AD9833_RESET 0b0000000100000000
77
#define AD9833_REG0 0
78
#define AD9833_REG1 1
79
#define AD9833_DOWN 0
80
#define AD9833_UP 1
81
#define AD9833_SIN 1
82
#define AD9833_TRIANGLE 2
83
#define AD9833_SQUARE 3
84
#define AD9833_FREQUENCY0_OUT 4
85
#define AD9833_FREQUENCY1_OUT 5
86
#define AD9833_PHASE0_OUT 6
87
#define AD9833_PHASE1_OUT 7
88
#define AD9833_SLEEP_MODE 9
89
#define AD9833_POWER_ON 10
90
91
92
//****************************************************************************************************
93
// PRIVATE FUNCTIONS (The user should not use it)
94
//****************************************************************************************************
95
106
void
AD9833_write_data
(
unsigned
int
data);
107
#define write_data_AD9833 AD9833_write_data
108
109
119
unsigned
int
AD9833_compose_control_word
(
unsigned
char
function_type);
120
#define compose_AD9833_control_word AD9833_compose_control_word
121
122
123
//****************************************************************************************************
124
// PUBLIC FUNCTIONS
125
//****************************************************************************************************
126
137
void
AD9833_initialize
(
unsigned
char
fmclk);
138
#define initialize_AD9833 AD9833_initialize
139
140
152
void
AD9833_set_frequency
(
unsigned
long
freq_value,
unsigned
char
frequency_register);
153
#define set_frequency_AD9833 AD9833_set_frequency
154
155
172
void
AD9833_tuning_frequency
(
unsigned
char
tuning_step,
unsigned
char
direction,
unsigned
char
frequency_register );
173
#define tuning_frequency_AD9833 AD9833_tuning_frequency
174
175
187
void
AD9833_set_phase
(
unsigned
long
phase_value,
unsigned
char
phase_register);
188
#define set_phase_AD9833 AD9833_set_phase
189
190
208
void
AD9833_set_function
(
unsigned
char
function_type);
209
#define set_function_AD9833 AD9833_set_function
210
211
212
#endif
213
214
215
216
217
LaurTec_PIC_libraries_v_3.3.1
inc
AD9833.h
Generated on Mon Jan 25 2016 20:51:56 for PIC18 LaurTec Library by
1.8.3.1