AnsweredAssumed Answered

FUD pin AD9858

Question asked by Dorney on Jul 7, 2011
Latest reply on Jul 13, 2011 by AndyR

Hello All!

 

I am trying to  program the AD9858 to output a single tone. The interface issue is getting the ATmega328 micro-controller and the AD9858 DDS to communicate over SPI.

 

How often should the FUD line be toggled, every 8 bits? after both the addr and data are sent? after each "phase"?

 

If anyone could please clear up my mind on this or share some of their code for AD9858. Thanks!

 

Below is the non-working code:

 

//------------------------------------------SPI Master---------------------------

#ifndef F_CPU
#define F_CPU 1000000UL //Defines Frequency to be 1MHz
#endif

#include <stdint.h>
#include <util/delay.h> // This will delay the program execution _delay_ms();
#include <avr/io.h>

 

//-----------Functions---------------------------------------

void spi_setup()
{
DDRB = 0b00101100;
SPCR= 0b01010000;
}


uint8_t spi_transmit(uint8_t data_byte)
{
SPDR=data_byte;
while(!(SPSR & (1<<SPIF)));
return SPDR;
}

void FUD_Toggle()
{

 

PORTD = (1<<PD2);
_delay_ms(1);
PORTD = (0<<PD2);
}


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

int main(void){
while(1){
  DDRD = 0b00000110;
  if (bit_is_set(PIND, PD0)) // I am using PD0 basically as a switch to start the program
  {
   PORTD=0b00000010; //Put an LED here
   _delay_ms(5000); //Use this delay time to set PD0 low
   PORTD=0b00000000;
   spi_setup();
  
   spi_transmit(00000000); //CFR ADDR
   FUD_Toggle();
  
   spi_transmit(00000000); //4 byte CFR
   spi_transmit(00000000);
   spi_transmit(00000000);
   spi_transmit(01011010);
   FUD_Toggle();
  
   spi_transmit(00000011);//FTW ADDR
   FUD_Toggle();
  
   spi_transmit(00001111);//4 byte FTW
   spi_transmit(01011100);
   spi_transmit(00101000);
   spi_transmit(11110110);
   FUD_Toggle();
  }
}
}

Outcomes