PIC18 LaurTec Library
3.1.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.1
5
Date : 08/12/2012
6
7
Last Update: Mauro Laurenti
8
Last Update: 02/02/2013
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 acknowledgment 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 RESET_AD9833 0b0000000100000000
77
#define REG0 0
78
#define REG1 1
79
#define DOWN 0
80
#define UP 1
81
#define SIN 1
82
#define TRIANGLE 2
83
#define SQUARE 3
84
#define FREQUENCY0_OUT 4
85
#define FREQUENCY1_OUT 5
86
#define PHASE0_OUT 6
87
#define PHASE1_OUT 7
88
#define SLEEP_MODE 9
89
#define POWER_ON 10
90
91
92
//****************************************************************************************************
93
// PRIVATE FUNCTIONS (The user should not use it)
94
//****************************************************************************************************
95
106
void
write_data_AD9833
(
unsigned
int
data);
107
108
118
unsigned
int
compose_AD9833_control_word
(
unsigned
char
function_type);
119
120
121
//****************************************************************************************************
122
// PUBLIC FUNCTIONS
123
//****************************************************************************************************
124
135
void
initialize_AD9833
(
unsigned
char
fmclk);
136
137
149
void
set_frequency_AD9833
(
unsigned
long
freq_value,
unsigned
char
frequency_register);
150
151
168
void
tuning_frequency_AD9833
(
unsigned
char
tuning_step,
unsigned
char
direction,
unsigned
char
frequency_register );
169
170
182
void
set_phase_AD9833
(
unsigned
short
long
phase_value,
unsigned
char
phase_register);
183
184
202
void
set_function_AD9833
(
unsigned
char
function_type);
203
204
205
206
#endif
207
208
209
210
211
LaurTec_PIC_libraries_v_3.1.1
inc
AD9833.h
Generated on Mon Oct 21 2013 19:59:45 for PIC18 LaurTec Library by
1.8.3.1