AnsweredAssumed Answered

AD9859 evaluation board does not work correctly

Question asked by ZheLiEdinburgh on Jul 21, 2015
Latest reply on Aug 18, 2015 by sitti

I got an AD9859 evaluation board and I tried to use mbed to communciate with AD9859 through SPI interface. I write some vaules to these registers and read someone but there is no responding and I could only get something like 0xFF. 

The code of mbed is shown below. It's a simple code which can only write register value and read someone. The pins I used is declared in my code. I tried to read one byte of FTW0 register and show it on mbed LED but all LEDs were lighted all the time. Also, there is no output signal on the IOUT dut1 and IOUT dut2.

 

#include "mbed.h"

SPI spi(p5, p6, p7); //mosi, miso, sclk
BusOut cs(p8,p25);  //cs = 0: all chips select; cs = 1: p25 select; cs = 2: p8 select; cs = 3: no chip select
BusOut reset(p21,p22);// reset = 0: no chip reset; reset = 1: p21 reset; reset = 2: p22 reset; reset = 3: all chips reset
BusOut ioupdate(p23,p24);//ioupdate = 0: no chip update; ioupdate = 1: p23 update IO; ioupdate = 2: p24 updateIO; ioupdate = 3: all chips update IO
BusOut iosync(p26,p27);//iosync = 0: no chip IO reset; iosync = 1: p27 IO reset; iosync = 2: p26 IO reset; iosync = 3: all chips IO reset
BusOut myleds(LED1, LED2, LED3, LED4);
BusOut CLKMODESELECT(p28,p29);  // Set high all the time

void SpiWrite(int addr, int data[4], int datalength, int CS);    //CS = 1/2/3 
int SpiRead(int addr, int datalength, int CS);
void SpiInitial();

int CFR1[4]={0x00,0x00,0x02,0x00};  // valid bytes: 4   //addr:0x00
int CFR2[4]={0x00,0x02,0x10,0x00};  // valid bytes: 3   //addr:0x01
int ASF[4]={0xA0,0x80,0x00,0x00};   // valid bytes: 2   //addr:0x02
int ARR[4]={0x80,0x00,0x00,0x00};   // valid bytes: 1   //addr:0x03
int FTW0[4]={0x01,0x01,0x01,0x01};  // valid bytes: 4   //addr:0x04
int POW0[4]={0x00,0x00,0x00,0x00};  // valid bytes: 2   //addr:0x05
int buffer = 0;

int main() {
    reset = 3;
    iosync = 3;
    cs = 3;
    CLKMODESELECT = 3;
    ioupdate = 0;
    wait(0.2);
    iosync = 0;
    reset = 0;    
    SpiInitial();
    while(1) {
        myleds = 1;
        wait(0.2);
        myleds = 3;
        wait(0.2);
        myleds = 7;
        wait(0.2);
        myleds = 15;
        wait(0.2);
        buffer = SpiRead(0x84, 2, 1);
        if (buffer > 15){
        myleds = buffer % 16;}
        else myleds = buffer;
        wait(2);
    }
}

void SpiInitial(){
    spi.format(8,3);
    spi.frequency(1000000);
    SpiWrite(0x00,CFR1,4,3);
    SpiWrite(0x01,CFR2,3,3);
    SpiWrite(0x02,ASF,2,3);
    SpiWrite(0x03,ARR,1,3);
    SpiWrite(0x04,FTW0,4,3);
    SpiWrite(0x05,POW0,2,3);
}

void SpiWrite(int addr, int data[4], int datalength, int CS)
{
    //iosync = 3 - CS;
    cs = 3 - CS;
    spi.write(addr);
    for(int i=0;i<datalength;i++){spi.write(data[i]);}
    cs = 3;
    ioupdate = CS;
    for(int i=0; i<30;i++){}
    ioupdate = 0;
    //iosync = 3;
}

int SpiRead(int addr, int datalength, int CS){
    int data[4] = {0};
    cs = 3 - CS;
    spi.write(addr);
    for(int i=0;i<datalength;i++){data[3-i] = spi.write(0x00);}
    cs = 3;
    return data[4 -datalength];
}

 

I also use scope to check the SPI clock and output data. Both of them are correct and exactly the same as the example on the datasheet of AD9859.

AD9859 evaluation board has limited interfaces, I don't really know what's going on. The power I used is: 1.8V for AVDD and DVDD, 3.3V for VCC and DVDD_I/O. Hope someone could help me to set up AD9859-eval. Thanks in advanced.

Outcomes