AnsweredAssumed Answered

How to synchronize three AD9832 DSS devices sharing the same MCLK.

Question asked by waterman on Nov 10, 2010
Latest reply on Mar 18, 2013 by nikolaslibert

Dear all,

I am new to use of digital direct synthesis devices. I am designing a mainboard for a photoacoustic instrument.

This mainboard must generate three frequencies F1-F3 at three individually different phases PH1-PH3:

F1 = 16384Hz @ PH1

F2 = 32768Hz @ PH2

F3 = 49152Hz @ PH3

 

The frequencies and phases are intended to be set up during  initialization of the three DSS. The attached pdf file shows how the  three AD9832 are connected.

 

Here are some summary:

 

-All three share the SPI bus.

 

-They share the same SPI_SCLK

 

-They share the same MCLK

 

-The MCLK can be started / stopped any time and run at stable 6.4MHz. Clean output with little ringing.

 

-Only FREQ0 and PHASE0 registers are used.

 

 

Problem:

 

I get the correct frequencies out from the AD9832s, but the phase  between the three outputs seems to be random even though I have set them  all to 0.

 

During several power up with the same code I get random phase shift between the three channels. They should be in phase.

 

I can correctly change the frequency of any three of the AD9832 at any time.

 

I can correctly change the phase of any three of the AD9832 at any time.

 

What should I do to synchronize these three AD9832s? Is it possible with the connections made?

 

 

Init procedure:

 

Turn off the shared MCLK.

 

Set all three in sleep mode.

 

Program all frequency registers of the AD9832s.

 

Program all phase registers of the AD9832s.

 

Take all three AD9832s out of sleep mode.

 

Turn on the shared MCLK.

 

 

void dss_init(void)

{

    //Send reset command to all three AD9832 and put them in sleep mode at the same time.

 

    DSS_PORT.OUTCLR = DSS_CS1_bm | DSS_CS2_bm;

 

    DSS3_PORT.OUTCLR = DSS_CS3_bm;

 

    SPIC_Transmit(0xF8);

 

    SPIC_Transmit(0x00);

 

    DSS_PORT.OUTSET = DSS_CS1_bm | DSS_CS2_bm;

 

    DSS3_PORT.OUTSET = DSS_CS3_bm;  

 

 

    //Set frequency

 

    dss_setFreq(0, &DSS2_PORT, DSS_CS2_bm);

 

    dss_setFreq(0, &DSS1_PORT, DSS_CS1_bm);

 

    dss_setFreq(0, &DSS3_PORT, DSS_CS3_bm);

 

 

 

    //Set phase

 

    dss_setPhase(0, &DSS1_PORT, DSS_CS1_bm);

 

    dss_setPhase(0, &DSS2_PORT, DSS_CS2_bm);

 

    dss_setPhase(0, &DSS3_PORT, DSS_CS3_bm);

 

 

    //Remove command to all three AD9832 and take them out of sleep mode at the same time.

 

    DSS_PORT.OUTCLR = DSS_CS1_bm | DSS_CS2_bm;

 

    DSS3_PORT.OUTCLR = DSS_CS3_bm;

 

    SPIC_Transmit(0xC0);

 

    SPIC_Transmit(0x00);

 

    DSS_PORT.OUTSET = DSS_CS1_bm | DSS_CS2_bm;

 

    DSS3_PORT.OUTSET = DSS_CS3_bm;  

 

 

 

    //START MCLK. NOW ALL THREE AD9832 get their first MCLKs.

 

    dss_mclk_start();

}

 

void dss_setFreq(unsigned long FREQ, PORT_t *deviceport, char CS_PIN)

 

{

 

 

    unsigned char FRQ0,FRQ1,FRQ2,FRQ3;

 

    FRQ0 = (unsigned char)FREQ;

 

    FRQ1 = (unsigned char)(FREQ>>8);

 

    FRQ2 = (unsigned char)(FREQ>>16);

 

    FRQ3 = (unsigned char)(FREQ>>24);

 

 

 

    deviceport->OUTCLR = CS_PIN;

 

    SPIC_Transmit(0x33);

 

    SPIC_Transmit(FRQ3);

 

    deviceport->OUTSET = CS_PIN;

 

 

    _delay_us(1);

 

 

 

    deviceport->OUTCLR = CS_PIN;

 

    SPIC_Transmit(0x22);

 

    SPIC_Transmit(FRQ2);

 

    deviceport->OUTSET = CS_PIN;

 

 

    _delay_us(1);

 

 

    deviceport->OUTCLR = CS_PIN;

 

    SPIC_Transmit(0x31);

 

    SPIC_Transmit(FRQ1);

 

    deviceport->OUTSET = CS_PIN;

 

 

    _delay_us(1);

 

 

    deviceport->OUTCLR = CS_PIN;

 

    SPIC_Transmit(0x20);

 

    SPIC_Transmit(FRQ0);

 

    deviceport->OUTSET = CS_PIN;  

 

 

 

}

 

 

 

void dss_setPhase(int phase, PORT_t *deviceport, char CS_PIN)

 

{

 

    unsigned char PLSB = (unsigned char)phase;

 

    unsigned char PMSB = (unsigned char)((phase>>8)&0x0f);

 

    dss_mclk_stop();

 

 

    deviceport->OUTCLR = CS_PIN;

 

    SPIC_Transmit(0x019);

 

    SPIC_Transmit(PMSB);

 

    deviceport->OUTSET = CS_PIN;

 

 

    _delay_us(1);

 

 

    deviceport->OUTCLR = CS_PIN;

 

    SPIC_Transmit(0x08);

 

    SPIC_Transmit(PLSB);

 

    deviceport->OUTSET = CS_PIN;

 

 

    dss_mclk_start();

 

}

Attachments

Outcomes