AnsweredAssumed Answered

AD9911 SPI Programming

Question asked by angrygrape on Jun 7, 2013
Latest reply on Jun 30, 2013 by angrygrape

I use PIC18LF4520 to configure registers in AD9911. My reference clock is 100MHz and I can get an 25MHz at Pin54(SYNC_CLK). However, I cannot get any signal at outp pins. I will attach the schematic and  C program. Any hint will be appreciated!

-------------------------------------------------------------------------------------

#pragma config OSC=HS

#pragma config PWRT=ON, BOREN=OFF

#pragma config WDT=OFF

#pragma config LVP=OFF //configuration bits setting

 

 

#include<p18cxxx.h>

#include<spi.h>

#include<delays.h>

#define uchar unsigned char

#define MRESET LATCbits.LATC1 //AD9911 master reset outpout, PORTC pin1

#define SYNC LATCbits.LATC2 //AD9911 SYNC_IO function output, PORTC pin2

#define SCK LATCbits.LATC3 //Serial CLK

#define SDO LATCbits.LATC5 //Serial Data Output

#define CSN LATDbits.LATD4 //CSN output pin, PORTD pin4

#define UPDATE LATDbits.LATD5 //AD9911 IO_UPDATE function output, PORTD pin5

#define PRO LATDbits.LATD6 //AD9911 Profile Pin1, PORTD pin6

 

 

void Initial(void);

void SPIiniti(void); //function prototypes

 

 

void main()

{

    Initial();

    SPIiniti();

    CSN=0; //CSN Low

    Delay100TCYx(50); //a delay in 2ms

          WriteSPI(0b00000000); //instruction byte, write operation, CSR

          WriteSPI(0b00100010); //Phase 2 of IO cycle, disable CH3\CH2\CH0,

    //enable CH1, bit3 must be 0, single bit serial(3-wire mode), MSB first

          WriteSPI(0b00000100); //CTW0 is accessed during phase 2, 4 bytes wide

    WriteSPI(0b00100000); //12.5MHz is expected, FTW, bits<31:24>

          WriteSPI(0b00000000); //bits<23:16>

    WriteSPI(0b00000000); //bits<15:8>

    WriteSPI(0b00000000); //bits<7:0>

    CSN=1; //CSN High

    UPDATE=1; //IO_UPDATE High, a rising edge triggers data transfer from the

    //IO port buffer to active registers

    Delay10TCYx(10); //a delay in 40us

    UPDATE=0; //IO_UPDATE Low

    while(1);

}

 

 

void Initial()

{

    INTCON=0x00;

    PIE1=0x00;

    PIE2=0x00;

          TRISCbits.TRISC1=0; //RESET output

    TRISCbits.TRISC2=0; //SYNC_IO output

          TRISCbits.TRISC3=0; //SCK output

          TRISCbits.TRISC5=0; //SDO output

    TRISDbits.TRISD4=0; //CSN output

    TRISDbits.TRISD5=0; //IO_UPDATE output

    TRISDbits.TRISD6=0; //Profile Pin1 output

    MRESET=1; //Issue a Master Reset

    Delay100TCYx(50); //a delay in 2ms

    MRESET=0; //Master Reset Low

    Delay100TCYx(50); //a delay in 2ms

          CSN=1; //CSN High

          SCK=0; //SCK Low

          SDO=0; //SDO Low

    SYNC=0; //SYNC_IO Low

    UPDATE=0; //IO_UPDATE Low

    PRO=0; //Profile Pin1 Low

}

 

 

void SPIiniti()

{

    OpenSPI(SPI_FOSC_64,MODE_01,SMPEND);

}

Attachments

Outcomes