AnsweredAssumed Answered

ADSP21478 Control ADAU1328 PLL lock indicator not locked Question

Question asked by Sea on Jan 7, 2013
Latest reply on Jan 18, 2013 by ColemanR

Hi I'm Sean

I use custom board for ADSP21478 .

I try to control ADAU1328.

But the PLL lock indicator register respond to "0".

How can I double check program  problem or Hardware problem?

The program is stop to the LockTest,becasue the PLL lock indicator register not respond to "1"

 

    LockTest = Get1939Register(0x1, ad1939_cs);

    while (!(LockTest & AD1938_PLL_LOCK))

    {

        LockTest = Get1939Register(CLKCTRL1, ad1939_cs);

        LockCount++;

    }

 

 

My custom Board codec use Quartz Crystal 12.288MHZ.
and the ADSP21478 use Quartz Crystal 25MHZ.

My CCLK is 200MHZ.

 

I use AD1939 Example code changes SPI CLK  Frequency is 500kHZ.

 

 

My Program are as follows

 

/* Setup the SPI parameters here in a buffer first */

unsigned char ConfigParam1939 [] = {

            (AD1939_ADDR), DACMUTE, 0x00,

            (AD1939_ADDR), CLKCTRL0, DIS_ADC_DAC | INPUT256 | PLL_IN_MCLK | MCLK_OUT_OFF | PLL_PWR_DWN,

            (AD1939_ADDR), CLKCTRL1, DAC_CLK_PLL | ADC_CLK_PLL | DIS_VREF,

            (AD1939_ADDR), DACCTRL0, DAC_FMT_I2S | DAC_BCLK_DLY_1 | DAC_SR_96K,

           (AD1939_ADDR), DACCTRL1,  DAC_BCLK_SLAVE| DAC_LRCLK_SLAVE  | DAC_CHANNELS_2 | DAC_LATCH_MID, //Ddebug

            (AD1939_ADDR), DACCTRL1,  DAC_BCLK_SLAVE| DAC_LRCLK_SLAVE  | DAC_CHANNELS_2 | DAC_LATCH_MID, //Ddebug

            (AD1939_ADDR), DACCTRL2, DAC_WIDTH_24,

      

            (AD1939_ADDR), ADCCTRL0, ADC_SR_96K,

 

            (AD1939_ADDR), ADCCTRL1, ADC_LATCH_MID | ADC_FMT_I2S | ADC_BCLK_DLY_1 | ADC_WIDTH_24,           

          

          (AD1939_ADDR), ADCCTRL2, ADC_BCLK_SRC_INTERNAL | ADC_BCLK_MASTER | ADC_CHANNELS_2 | ADC_LRCLK_MASTER  | ADC_LRCLK_FMT_50_50|ADC_LRCLK_POL_NORM|ADC_BCLK_POL_NORM, // NDdebug  

          (AD1939_ADDR), ADCCTRL2, ADC_BCLK_SRC_INTERNAL | ADC_BCLK_MASTER | ADC_CHANNELS_2 | ADC_LRCLK_MASTER  | ADC_LRCLK_FMT_50_50|ADC_LRCLK_POL_NORM|ADC_BCLK_POL_NORM, // NDdebug                 

          (AD1939_ADDR), DACVOL_L1, DACVOL_MAX,

            (AD1939_ADDR), DACVOL_R1, DACVOL_MAX,

            (AD1939_ADDR), DACVOL_L2, DACVOL_MAX,

            (AD1939_ADDR), DACVOL_R2, DACVOL_MAX,

            (AD1939_ADDR), DACVOL_L3, DACVOL_MAX,

            (AD1939_ADDR), DACVOL_R3, DACVOL_MAX,

            (AD1939_ADDR), DACVOL_L4, DACVOL_MAX,

            (AD1939_ADDR), DACVOL_R4, DACVOL_MAX,

            (AD1939_ADDR), CLKCTRL0, DIS_ADC_DAC | PLL_IN_MCLK | MCLK_OUT_OFF | INPUT256 | PLL_PWR_UP,

            (AD1939_ADDR), CLKCTRL0, ENA_ADC_DAC | PLL_IN_MCLK | MCLK_OUT_OFF | INPUT256 | PLL_PWR_UP,

            (AD1939_ADDR), DACMUTE, 0x00,

            } ;

 

 

 

 

unsigned char AD1938_Regs_Read[sizeof(ConfigParam1939) / 3];

unsigned char B_Test[sizeof(ConfigParam1939) / 3];

volatile int spiFlag ;

 

 

///////////////////////////////////////////////////////////////////////////////

// Set up the SPI port to access the AD1939

// Call with SPI flag to use

///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

 

 

void SetupSPI1939(unsigned int SPI_Flag)

{

    // Configure the SPI Control registers

    // First clear a few registers

    *pSPICTL = (TXFLSH | RXFLSH) ;

    *pSPIFLG = 0;

 

 

    // Setup the baud rate to 500kHz

    //*pSPIBAUD = 100;

    *pSPIBAUD = 100;

 

 

    // Setup the SPI Flag register using the Flag specified in the call

    *pSPIFLG = (0xF00|SPI_Flag);

 

 

    // Now setup the SPI Control register

    *pSPICTL = (SPIEN | SPIMS | WL8 | MSBF | TIMOD1 | CLKPL | CPHASE |SMLS|GM);//

}

 

 

///////////////////////////////////////////////////////////////////////////////

// Disable the SPI Port

///////////////////////////////////////////////////////////////////////////////

 

 

void DisableSPI1939(void)

{

    *pSPICTL = (TXFLSH | RXFLSH);

}

 

 

 

 

///////////////////////////////////////////////////////////////////////////////

// Send a word to the AD1939 via SPI

// Call with the AD1939 address, register address, register data,

// and SPI flag to use

///////////////////////////////////////////////////////////////////////////////

 

 

void Configure1939Register (unsigned char rwaddr,unsigned char regaddr,unsigned char regdata, unsigned int spiselect)

{

    int i,j;

    unsigned char val[3];

 

 

    SELECT_SPI_SLAVE(spiselect);

 

 

    val[0]=WR(rwaddr);

    val[1]=regaddr;

    val[2]=regdata;

 

 

    for(i=0;i<3;i++)

    {

        j=0;

        *pTXSPI = val[i] ;

        //Delay(136);

        //Wait for the SPI to indicate that it has finished.

        while ((*pSPISTAT & TXS))

        {j++;}

    }

 

 

    j=0;

    //Wait for the SPI to indicate that it has finished.

    while (!(*pSPISTAT & SPIFE))

    {j++;}

 

 

    Delay(13);

    DESELECT_SPI_SLAVE(spiselect);

 

 

}

 

 

 

 

///////////////////////////////////////////////////////////////////////////////

// Receive a register setting from the AD1939

// Call with the register address, and SPI flag to use; returns register data

///////////////////////////////////////////////////////////////////////////////

 

 

unsigned char Get1939Register (unsigned char regaddr, unsigned int spiselect)

{

    int i,j;

    unsigned char val[3];

    unsigned int tmp;

 

 

    SELECT_SPI_SLAVE(spiselect);

 

 

    val[0]=RD(AD1939_ADDR);

    val[1]=regaddr;

    val[2]=0;

    for(i=0;i<3;i++)

    {

        j=0;

        *pTXSPI = val[i] ;

 

 

        //Wait for the SPI to indicate that it has finished.

        while ((*pSPISTAT & TXS))

        {j++;}

    }

 

 

    j=0;

    //Wait for the SPI to indicate that it has finished.

    while (!(*pSPISTAT & SPIF))

    {j++;}

    while (!(*pSPISTAT & SPIFE))

    {j++;}

 

 

    Delay(13);

 

 

    tmp = *pRXSPI;

 

 

    DESELECT_SPI_SLAVE(spiselect);

 

 

    return tmp;

}

 

 

 

 

///////////////////////////////////////////////////////////////////////////////

// Set up all AD1939 registers via SPI

///////////////////////////////////////////////////////////////////////////////

 

 

int LockCount = 0;

unsigned int LockTest;

 

 

void Init1939viaSPI(int codec)

{

    int configSize = sizeof(ConfigParam1939);

    int j=0 ;

    unsigned char tmpA[sizeof(ConfigParam1939) / 3];

    unsigned int ad1939_cs;

          int i=0;

  

        ad1939_cs = DS0EN;

 

 

    //Set up AD1939

    SetupSPI1939(ad1939_cs);

 

 

    //Write register settings

    for(i = 0; i < configSize-6; i+=3)

    {

        Configure1939Register(ConfigParam1939[i], ConfigParam1939[i+1], ConfigParam1939[i+2], ad1939_cs);

        Delay(272);

 

 

        //Read back register settings for debugging

        AD1938_Regs_Read[j++] = Get1939Register(ConfigParam1939[i+1], ad1939_cs);

        Delay(272);

    }

 

 

 

 

    LockTest = Get1939Register(0x1, ad1939_cs);

    while (!(LockTest & AD1938_PLL_LOCK))

    {

        LockTest = Get1939Register(CLKCTRL1, ad1939_cs);

        LockCount++;

    }

 

 

    for(i = configSize-6; i < configSize; i+=3)

    {

        Configure1939Register(ConfigParam1939[i], ConfigParam1939[i+1], ConfigParam1939[i+2], ad1939_cs);

        Delay(272);

 

 

        //Read back register settings for debugging

        AD1938_Regs_Read[j++] = Get1939Register(ConfigParam1939[i+1], ad1939_cs);

        Delay(272);

    }

 

 

    DisableSPI1939();

}

 

 

 

 

 

 

//Delay loop

void Delay(int i)

{

    for(i ; i > 0; --i)

        asm("nop;");

}

 

 

My SPI protocol are as follows

SPI CLK is 500KHZ

Period is 2us

+Width is 998.ns

-Width is 1us

 

 

TCLH is 160ns

1.JPG

TLCS is 2.42us

3.JPG

TCCP is 1.82us

4.JPG

Outcomes