AnsweredAssumed Answered

AD9834 SPI Programming

Question asked by astro on Sep 17, 2015
Latest reply on Sep 18, 2015 by astro

Hi,

 

I am trying to program an AD9834, but for some reason the outputs are both simply around 300mV DC (with some high frequency noise).

 

The circuit is the same as the evaluation board design.

 

I am programming it via SPI with a PIC MCU.

Here is the output of the programming pins:

2.jpg

 

 

 

And the program if it is useful (compiled in MikroC):

 

 

 

void SPIWrite16(unsigned short databit) {

 

        unsigned char MSdata = ((databit>>8) & 0x00FF);          //MSB

        unsigned char LSdata = (databit & 0x00FF);                        //LSB

       

PORTD.F1=0 ;

//Delay_us(1);

SPI1_Write(MSdata);

SPI1_Write(LSdata);

PORTD.F1=1 ;

     }

 

 

void main() {

  TRISD = 0;

  PORTD.F1=1 ;

SPI1_Init();

SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_HIGH_2_LOW);

 

Delay_us(100);

  

    SPIWrite16(0x2100);          // control word

    SPIWrite16(0x5AC7);         // Freq         

    SPIWrite16(0x5A63);           // Freq

    SPIWrite16(0xC000);          // phase

    SPIWrite16(0x2000);          // control word

 

}

 

 

 

 

Anyone know what I am doing wrong?

 

Thanks!

Outcomes