AnsweredAssumed Answered

AD9858 SPI Interface

Question asked by Dorney on Jul 12, 2011
Latest reply on Jul 13, 2011 by Dorney

Hello All,

 

I am working with an AD9858 DDS, specifically the "DDS DAC Output Evaluation Board. To control the frequency I am trying to use an ATmega328 micro-controller programmed in AVR Studio.

 

I have checked the SPI sck and mosi outputs using an oscilloscope, seems to be working fine. The clock reference is 1Ghz at -5dBm. All other settings can be seen in the code below (also attached to avoid any formatting issues). Despite my continued efforts the DDS will not spit out the 60MHz I want it to.

 

Does anyone have their own SPI code for interfacing uC and AD9858 that they are willing to share?

 

Is there something else I am missing?

 

Thanks!

 

 

void

spi_setup()

{

 

DDRB = 0b00101101;

 

SPCR= 0b01010000;

}

 

  

int

spi_transmit(int data_byte)

{

 

SPDR=data_byte;

 

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

 

return SPDR;

}

void

FUD_Toggle()

{

 

 

PORTD = (1<<PD2);

 

_delay_ms(5000);

 

PORTD = (0<<PD2);

}

  

//-----------------Main Program--------------------------------------

int

main(void){

 

while(1){

 

DDRD = 0b11111110;

 

 

if (bit_is_set(PIND, PD0))

 

{

 

PORTD=(1<<PD1); //Put an LED here

 

_delay_ms(5000); //Use this delay time to set PD0 low (a switch)

 

PORTD=(0<<PD1);

 

 

PORTD=(1<<PD3); //Toggle the reset line

 

_delay_ms(5000);

 

PORTD=(0<<PD3);

 

 

PORTD=(0<<PD4); //Set PS0 to low

 

PORTD=(0<<PD5); //Set PS1 to low

 

PORTD=(0<<PD6); //Set SPSelect to low

 

PORTD=(0<<PD7); //Set CS to low

 

 

 

spi_setup();

 

 

spi_transmit(0b00000000); //CFR ADDR

 

//_delay_ms(5000);

 

FUD_Toggle();

 

 

spi_transmit(0b00000000); //4 byte CFR

 

//_delay_ms(5000);

 

spi_transmit(0b00000000);

 

//_delay_ms(5000);

 

spi_transmit(0b00000000);

 

//_delay_ms(5000);

 

spi_transmit(0b01011010);

 

//_delay_ms(5000);

 

FUD_Toggle();

 

 

spi_transmit(0b00000011);//FTW ADDR

 

//_delay_ms(5000);

 

FUD_Toggle();

 

 

spi_transmit(0b00001111);//4 byte FTW

 

//_delay_ms(5000);

 

spi_transmit(0b01011100);

 

//_delay_ms(5000);

 

spi_transmit(0b00101000);

 

//_delay_ms(5000);

 

spi_transmit(0b11110110);

 

//_delay_ms(5000);

 

FUD_Toggle();

 

 

PORTD=(1<<PD1); //Signals the end of SPI transmissions

 

_delay_ms(5000);

 

PORTD=(0<<PD1);

 

}

 

}

}

 

Attachments

Outcomes