AnsweredAssumed Answered

AD 9858 DDS interfacing with ADUC 847

Question asked by ABH on Apr 22, 2013
Latest reply on Apr 26, 2013 by Kevin.G

Hi,  i am working with DDS evaluation board AD9858, i want to  generate the fixed 100MHZ  frequency for that i am using a SPI interface between  ADUC 847 Microcontroller and AD9858. i wrote the code but i m not able to get any output.Can anybody  help me to sort out the problem?

 

 

#include<ADUC847.h>

#include<stdio.h>

sbit sclk=P2^0;

sbit mosi=P2^1;

sbit miso=P2^2;

sbit cs=P2^3;

sbit fud=P0^0;

sbit ps0=P0^1;

sbit ps1=P0^2;

sbit spmode=P0^3;

sbit ioreset=P0^4;

sbit reset=P0^5;

 

void spi_setup()

{

          cs=1;

          ps0=0;

          ps1=0;

          fud=1;

          spmode=0;

          ioreset=0;

          reset=1;

          SPICON=0X33;

}

int spi_transmit(unsigned char byte_data)

{

  cs=0;

  SPIDAT=byte_data;

  while(ISPI!=1);

  return(SPIDAT);

    cs=1;

 

 

}

void delay(unsigned int time)

{

          unsigned int i,j;

          for(i=0;i <time;i++);

          for(j=0;j <100;j++) ;

}

void FUD_Toggle()

{

          fud=1;

          delay(5);

          fud=0;

}

void main()

{

P0=0xFF;

P2=0xFF;

          ioreset=1;

          delay(5);

          ioreset=0;

           reset=1;

          delay(5);

          reset=0;

          cs=0;

 

                                                            spi_setup();

 

                                                            spi_transmit(0x00);                                                             //CFR ADDR

 

                                                            FUD_Toggle();

                                                            delay(5);

 

 

                                                            spi_transmit(0x00);                                                             //4 byte CFR

 

                                                            spi_transmit(0x00);

 

                                                            spi_transmit(0x00);

 

                                                            spi_transmit(0x5A);

 

                                                            FUD_Toggle();

                                                            delay(50);

 

 

                                                              spi_transmit(0x03);                                                            //FTW ADDR

 

 

 

                                                            FUD_Toggle();

                                                            delay(5);

 

                                                            spi_transmit(0x19);                                                            //4 byte FTW

 

                                                            spi_transmit(0x99);

 

                                                            spi_transmit(0x99);

                                                                                                                                            

                                                            spi_transmit(0x9A);

 

                                                            FUD_Toggle();

}

Attachments

Outcomes