Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved] Sine wave from AD9833

Status
Not open for further replies.

vineet_barc

Newbie level 2
Joined
Oct 7, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
mumbai
Activity points
1,311
Unable to generate sine wave from AD9833.... using MSP430FG4618 micro-controller....

************* Code *************

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "msp430xG46x.h"
 
#define FSYNC_AD9833_DIR    P4DIR |= BIT6;
#define FSYNC_AD9833_HIGH   P4OUT |= BIT6;    // Set FSYNC HIGH
#define FSYNC_AD9833_LOW    P4OUT &= ~BIT6;    // Set FSYNC LOW
 
#define AD9833_REG_CMD      (0 << 14)
#define AD9833_REG_FREQ0    (1 << 14)
#define AD9833_REG_FREQ1    (2 << 14)
#define AD9833_REG_PHASE0   (6 << 13)
#define AD9833_REG_PHASE1   (7 << 13)
 
/* Command Control Bits */
 
#define AD9833_B28          (1 << 13)
#define AD9833_HLB          (1 << 12)
#define AD9833_FSEL0        (0 << 11)
#define AD9833_FSEL1        (1 << 11)
#define AD9833_PSEL0        (0 << 10)
#define AD9833_PSEL1        (1 << 10)
#define AD9833_PIN_SW       (1 << 9)
#define AD9833_RESET        (1 << 8)
#define AD9833_SLEEP1       (1 << 7)
#define AD9833_SLEEP12      (1 << 6)
#define AD9833_OPBITEN      (1 << 5)
#define AD9833_SIGN_PIB     (1 << 4)
#define AD9833_DIV2         (1 << 3)
#define AD9833_MODE         (1 << 1)
 
#define AD9833_OUT_SINUS    ((0 << 5) | (0 << 1) | (0 << 3))
#define AD9833_OUT_TRIANGLE ((0 << 5) | (1 << 1) | (0 << 3))
#define AD9833_OUT_MSB      ((1 << 5) | (0 << 1) | (1 << 3))
#define AD9833_OUT_MSB2     ((1 << 5) | (0 << 1) | (0 << 3))
 
void AD9833_Write_Word(unsigned int value)
{
    int i;
    char clsb, cmsb;
 
    clsb = (char)value;
    cmsb = value >> 8;
 
    FSYNC_AD9833_LOW
    for(i=5;i>0;i--){}          // delay
 
    while (!(IFG2 & UTXIFG1));  // USART1 TX buffer ready?
    U1TXBUF = cmsb;             //send_AD9833char(cmsb);
    while (!(IFG2 & UTXIFG1));  // USART1 TX buffer ready?
    U1TXBUF = clsb;             //send_AD9833char(clsb);
    while (!(IFG2 & UTXIFG1));  // USART1 TX buffer ready?
 
    for(i=10;i>0;i--){}         // delay
    FSYNC_AD9833_HIGH
 
}// AD9833_Write_Word
 
void main()    // ##################################
{
    int i;
 
    WDTCTL = WDTPW + WDTHOLD;           // Stop watchdog timer
 
    FLL_CTL0 |= XCAP14PF;               // Configure load caps
    do // Wait for xtal to stabilize
    {
        IFG1 &= ~OFIFG;                 // Clear OSCFault flag
        for (i = 0x47FF; i > 0; i--);   // Time for flag to set
    }
    while ((IFG1 & OFIFG));             // OSCFault flag still set?
 
    FSYNC_AD9833_DIR                       
    FSYNC_AD9833_HIGH                   
 
    P4SEL |= 0x28;              // P4.3 & P4.5 = SPI SIMO1 & UCLK1
    U1CTL |= SWRST;             // USART logic held in RESET state
    U1CTL |= CHAR|SYNC|MM;      // 8-bit data, SPI mode, Mater mode
 
    U1TCTL |= CKPL|SSEL1|STC;
    U1BR1 = 0;                  // Baud Rate = 131072
    U1BR0 = 8;                                
    U1MCTL = 0x000;                        
 
    ME2 |= USPIE1;              // Enables the SPI mode for USART1
    U1CTL &= ~SWRST;            // USART RESET released for operation
   
    AD9833_Write_Word(0x2100);
    AD9833_Write_Word(0x50C7);  // For Generating Sinwave of
    AD9833_Write_Word(0x4000);  // 400Hz...as per Application Note
    AD9833_Write_Word(0xC000);  // AN-1070
    AD9833_Write_Word(0x2000);
 
     while(1){}
 
 
}// main

 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top