Hi! I am trying to build a sine waveform generator using ad9832. I already read the topics here with another people having problems with ad9832 but i didn't find the answer so i decided to post this question as a new one.

The problem is, that i am getting nothing on the output of ad9832, but in my opinion the communication with dds is correct (i have programming examples from AD). I attached my schematic to this post. Everything is similar to the datasheet of the ad9832, except the capacitor beetwen refin and agnd (i used 100nF instead of 10nF, does it make any difference ?). Very important thing is, that when i am measuring dc voltage beetwen refout and agnd i am getting something about 200mV. Here is the code for uC which steers ad9832:

void Podziel_Slowo(void)

{

czesc_slowa[0] = (uint8_t)(slowo&255); // less important 8 bits

czesc_slowa[1] = (uint8_t)((slowo>>8)&255);

czesc_slowa[2] = (uint8_t)((slowo>>16)&255);

czesc_slowa[3] = (uint8_t)((slowo>>24)&255); // most important 8 bits

}// this function divides 32-bit frequency word into the 8-bits parts

void InitSoftSPI_DDS(void)

{

//outputs MOSI, SCK, CS

DDRD |= (1<<DMOSI)|(1<<DSCK)|(1<<DCS);

PORTD |= (1<<DMOSI)|(1<<DSCK)|(1<<DCS); // everything on "1" at the beggining

}//this one inits the uC pins for soft spi communication

//here are the definitions:

#define DMOSI PD3

#define DSCK PD4

#define DCS PD5

#define DSCK_0 PORTD &= ~(1<<DSCK)

#define DSCK_1 PORTD |= (1<<DSCK)

#define DMOSI_0 PORTD &= ~(1<<DMOSI)

#define DMOSI_1 PORTD |= (1<<DMOSI)

//this function is an spi communication (sends 8-bit data)

void SendSoftSPI_DDS(uint8_t bajt)

{

uint8_t cnt = 128; //0b10000000

while(cnt)

{

_delay_ms(4);

if(bajt&cnt) DMOSI_1;

else DMOSI_0;

_delay_ms(3); //3000

DSCK_0;

_delay_ms(3);  //3000

DSCK_1;

cnt>>=1; //cnt = cnt>>1

}

}

//and finally this is the function which program dds:

void Wyslij_Freq_pozazakresem(void)

{

Podziel_Slowo();

PORTD &= ~(1<<DCS);    //set 0 on CS (communication active)

SendSoftSPI_DDS(0b11111000);//turn dds into programming mode

SendSoftSPI_DDS(0b00000000);//data = dont care

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);  //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00110000); / FREQ0 8L LSB

SendSoftSPI_DDS(czesc_slowa[0]); //data

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00100001); //iFREQ0 8H LSB

SendSoftSPI_DDS(czesc_slowa[1]);

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);  //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00110010); //FREQ0 8L MSB

SendSoftSPI_DDS(czesc_slowa[2]);

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00100011);    //FREQ1 8L LSB

SendSoftSPI_DDS(czesc_slowa[3]);

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

//-------------------- freq1 ----------------------------

SendSoftSPI_DDS(0b00110100);

SendSoftSPI_DDS(czesc_slowa[0]); //freq1 8l lsb

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00100101);

SendSoftSPI_DDS(czesc_slowa[1]); //freq1 8h lsb

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00110110);

SendSoftSPI_DDS(czesc_slowa[2]); //freq1 8l msb

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00100111);

SendSoftSPI_DDS(czesc_slowa[3]); //freq1 8h msb

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

//----------------phase registers = we will wrtie zeros----------------------------------

SendSoftSPI_DDS(0b00011000); //ph0 8 lsb

SendSoftSPI_DDS(0b00000000); //

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00001001); //ph0 8 msb

SendSoftSPI_DDS(0b00000000); //

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00011010); //ph1 8 lsb

SendSoftSPI_DDS(0b00000000); //

_delay_ms(2);

PORTD |= (1<<DCS); //)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00001011); //ph1 8 msb

SendSoftSPI_DDS(0b00000000); /

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00011100); //ph2 8 lsb

SendSoftSPI_DDS(0b00000000); //

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00001101); //ph2 8 msb

SendSoftSPI_DDS(0b00000000); //

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00011110); //ph3 8 lsb

SendSoftSPI_DDS(0b00000000); //

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00001111); //ph3 8 msb

SendSoftSPI_DDS(0b00000000); //

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

//----------------selsrc i sync-----------

SendSoftSPI_DDS(0b10000000);

SendSoftSPI_DDS(0b00000000);

_delay_ms(2);

PORTD |= (1<<DCS); //

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b11000000);

SendSoftSPI_DDS(0b00000000); // wake up ang generate : )

_delay_ms(2);

PORTD |= (1<<DCS); //

}//

I would like to add that the fselect pin is tied to gnd (i am using pins to select freq registers)

Today at school i checked the spi communication on the osciloscope and it looked correct (sorry i didn't shot any photo's).

Is it possible that ad9832 is broken or something ?

schemat1_black.pdf
• hey! i was just able to get signal on the output using the code below, but the frequency using this code should be something about 22kHz but on the output the frequency is randomly from 3Hz to 60hz (my MCLK is 24Mhz). I noticed that vref = 1.21 V only for a 1 second (right after sending data), and after that it comes back to 200mV. Shouldn't it be 1.21 V for a whole time the signal is being generated ?

here is the code, which generates this strange thing:(this time i didn't divided 32-bit frequency word, i just put the data into the instruction)

void Wyslij_9_9khz(void)

{

PORTD &= ~(1<<DCS);    //ustaw 0 na CS (transmisja aktywna)

SendSoftSPI_DDS(0b11111000);//wprowadz ddsa w tryb programowania

SendSoftSPI_DDS(0b00000000);//wprowadz ddsa w tryb programowania (dana dont care)

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);  //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00110000); //instrukcja zapisu do FREQ0 8L LSB

SendSoftSPI_DDS(0b00110100); //dana

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00100001); //intrukcja zapisu do FREQ0 8H LSB

SendSoftSPI_DDS(0b00010001);

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);  //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00110010); //zapis do FREQ0 8L MSB

SendSoftSPI_DDS(0b00110110);

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00100011);    //zapis do FREQ0 8H MSB

SendSoftSPI_DDS(0b00000000);

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

//--------------------tera do freq1 wpiszemy 10.4khz----------------------------

SendSoftSPI_DDS(0b00110100);

SendSoftSPI_DDS(0b01000001); //freq1 8l lsb

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00100101);

SendSoftSPI_DDS(0b11001100); //freq1 8h lsb

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00110110);

SendSoftSPI_DDS(0b00111000); //freq1 8l msb

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00100111);

SendSoftSPI_DDS(0b00000000); //freq1 8h msb

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

//----------------teraz wpis do rejestrow fazy----------------------------------

SendSoftSPI_DDS(0b00011000); //ph0 8 lsb

SendSoftSPI_DDS(0b00000000); //wpisujemy tam zera

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00001001); //ph0 8 msb

SendSoftSPI_DDS(0b00000000); //wpisujemy tam zera

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00011010); //ph1 8 lsb

SendSoftSPI_DDS(0b00000000); //wpisujemy tam zera

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00001011); //ph1 8 msb

SendSoftSPI_DDS(0b00000000); //wpisujemy tam zera

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00011100); //ph2 8 lsb

SendSoftSPI_DDS(0b00000000); //wpisujemy tam zera

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00001101); //ph2 8 msb

SendSoftSPI_DDS(0b00000000); //wpisujemy tam zera

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00011110); //ph3 8 lsb

SendSoftSPI_DDS(0b00000000); //wpisujemy tam zera

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b00001111); //ph3 8 msb

SendSoftSPI_DDS(0b00000000); //wpisujemy tam zera

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

//----------------teraz wybor selsrc i sync, bedziemy sterowac pinami-----------

SendSoftSPI_DDS(0b10000000);

SendSoftSPI_DDS(0b00000000);

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

_delay_ms(2);    //2000

PORTD &= ~(1<<DCS);

SendSoftSPI_DDS(0b11000000);

SendSoftSPI_DDS(0b00000000); //przebudzenie z programowania i generacja

_delay_ms(2);

PORTD |= (1<<DCS); //ustaw 1 na CS (zatrzask 16 bitów)

}// koniec Wyslij_9_9khz

• Hello Alf,

Yes it should be 1.21v all the time.  I haven't read through your code yet but perhaps you are putting the part to sleep somehow or entering the reserved test mode?

• Hello everyone!

I solved my problem. PSEL0 and PSEL1 pins were tied together to gnd. Maybe that's why i was able to get nothing or random freqs on the output. When i had disconnected them from gnd and had left them floating, everything started to work... great! : ) Now my  project (signal generator using DDS technique) is completely done and 100% working! Hope i will get a good mark from a teacher ; )