AnsweredAssumed Answered

Problems about AD9835!!!

Question asked by minhaaa on Sep 30, 2010
Latest reply on Oct 4, 2010 by LiamR

When I attach PIC 16F887 to the Evaluation board on Datasheet( in which pin 10,11,1 connect to DGND and pin2 connects to pin 3)  to control the AD9835, PIC has 3 pins to control AD9835 like this:

 

//   7--->SCLK   --->   17--->RC2
//   8--->SDATA   --->   16--->RC1
//   9--->FSYNC   --->   15--->RC0

 

To generate sine wave  1-15Mhz frequency with  MCLK 50Mhz we have 4 functions programming for PIC but there is not any sine signal at the output (pin 14)  I don't know where the problem is. Can you find out the errors for me????

 

#define FSYNC   PIN_C0
#define SDATA   PIN_C1
#define SCLK     PIN_C2

function 1 :

void SendWord16ToAD9835 ( unsigned int DDSWord)
{
   int i;
   output_high(SCLK);
   output_high(FSYNC);    for(i=0; i<16;i++)
   {
      if((DDSWord&(1<<(15-i)))==0)

 

   output_low(FSYNC);
   delay_cycles(5);
  
       {
         output_low(SDATA);
      }
      else
      {
         output_high(SDATA);  

      }
      output_high(SCLK);delay_cycles(5);
      output_low(SCLK);delay_cycles(5);

      }
   output_high(FSYNC);

}

 

function 2 :

 

void SendWord32ToAD9835 ( unsigned long DDSWord32)
{
   unsigned int word16;                
   unsigned long int tam;
   tam=DDSWord32;
   tam=tam&0x000000ff;  
   word16=(unsigned int)(0x3000+(tam));        //  8bit L LSB
   SendWord16ToAD9835(word16);
   tam=DDSWord32;
   tam=tam&0x0000ff00;
   word16=(unsigned int)(0x2100+(tam>>=8)); //    8bit H LSB
   SendWord16ToAD9835(word16);
   tam=DDSWord32;
   tam=tam&0x00ff0000;
   word16=(unsigned int)(0x3200+(tam>>=16))     ;// 8bit L MSB
   SendWord16ToAD9835(word16);
   tam=DDSWord32;
   tam=tam&0xff000000;
   word16=(unsigned int)(0x2300+(tam>>=24)); // 8bit H MSB
   SendWord16ToAD9835(word16);
}

function 3:

 

unsigned long int ConvertFrequency(unsigned long int tem   )

{
   unsigned long int c;
   c=(unsigned long int)(temp/11.64153218e-3);
   return(c);
}

 

function4:

 

void initAD9835 ( void )
{
   SendWord16ToAD9835(0xF800);
   SendWord16ToAD9835(0xB000);
   SendWord16ToAD9835(0x5000);
   SendWord16ToAD9835(0x4000);
   SendWord16ToAD9835(0x1800);
   SendWord16ToAD9835(0x0900);
   SendWord32ToAD9835(ConvertFrequency(1000));  
   SendWord16ToAD9835(0xC000);
}

Outcomes