AnsweredAssumed Answered

AD5620 as amplitude control AD9834

Question asked by zigler on Mar 6, 2013
Latest reply on Apr 10, 2013 by musach

Hi,

I have to do Sinus generator based on AD9834 with amplitude control AD5620.

I have become Sinus on output of AD9834, but it looks like AD5620 doesn't work.

I can not set output voltage of AD5620 wiht ATmega16, does not respond to SPI interfacing.

 

My AD9834+AD5620 circuit is attached. Can you plz check, is it alright or not?

I try to communicate with AD5620 following code (AVR Studio 5.1):

 

#define DDR_SPI        DDRB

#define DD_MOSI        5

#define DD_SCK        7

#define DD_CS        4

#define DD_DAC_CS    0

 

// set CS to 0 = active

#define CSACTIVE DDR_SPI &= ~(1<<DD_DAC_CS)

// set CS to 1 = passive

#define CSPASSIVE DDR_SPI |= (1<<DD_DAC_CS)

//

#define waitspi() while(!(SPSR&(1<<SPIF)))

 

void AD5620_SPI_INIT()

{

   DDR_SPI |= (1<<DD_MOSI)|(1<<DD_SCK)|(1<<DD_DAC_CS);

   SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<CPOL);

}

 

void spi_ad_16(unsigned short data)

{

    unsigned char MSdata = ((data >>8) & 0x00FF);

    unsigned char LSdata = (data & 0x00FF);

 

    SPDR = MSdata;

    while(!(SPSR & (1<<SPIF)));

    SPDR = LSdata;

    while(!(SPSR & (1<<SPIF)));

}

 

while(1)

{

CSACTIVE;

spi_ad_16(0x0000);    // 00.0...0.00 - U = 0V

CSPASSIVE;

 

_delay_ms(1000);

 

CSACTIVE;

spi_ad_16(0x2000);    // 00.0100.0000.0000.00 = 1024, 1024/4096 = 0.25*2.5V = 0.625

CSPASSIVE;

}

 

P.S. Sorry for my English

Attachments

Outcomes