This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

McBSP loopback not working , when FSGM=0

I have configured McBSP0  using  internal clock in DLB mode with FSX generation on every DXR to XSR copy. I can see that 1st data is copied to DXR, but it is not recieved at DRR. The RRDY bit is not getting enabled. Hence code is getting stuck at that condition check of RRDY. What could be the reason that RRDY is not getting enabled, when i see that data is being transmitted.

The code is as given below:

void McBSP_initDLB(McBSP_reg *McBSP)
{while(McBSP->SPCR & 0x00C00000);       

McBSP->SPCR = 0x0000;

McBSP->SPCR |= (0x1 << 15) ;

McBSP->PCR |=(0x1<<11)|(0x1<<9)|(0x0<<8)|(0x1<<10);     / / FSXM=1,FSRM=1,CLKXM=CLKRM=1

McBSP->SRGR =(0x0<<28); // FSGM =0

McBSP->XCR = 0x040;

McBSP->RCR = 0x040;

while(McBSP->SPCR & 0x00C00000);       // Ensure GRST = FRST = 0
while(McBSP->SPCR & 0x00010001);       // Ensure RRST = XRST = 0

wait(2*100);
 McBSP->SRGR |=(0x1<<29); //CLKSM  1-> McBSP internal clock

McBSP->PCR &= (~0x80);     // SCLKME = 0

McBSP->SPCR |= (0x1<<22); //set GRST=1
wait(2*100);

McBSP->SPCR |= (0x1<<16);                // XRST =1
wait(2*100);                             // Wait for 2 CLKG cycles
McBSP->SPCR &= ~(0x1<<16);                //XRST =0 to clear XSYNCERR that might have occur

McBSP->SPCR |=0x00010001;         // XRST = RRST = 1

}

//Function to transmit

void  write(signed short int data1,McBSP_reg *Port)
{

while(!(Port->SPCR & (0x1<<17)));   // Wait until transmitter is ready for new data in DXR(XRDY=1)
Port->DXR = data1;   

}

 

//Function to recieve

void read()

{

while(!((McBSP0->SPCR)& 0x2)); //Ensure RRDY =1. Data is ready to be read from DRR
data = McBSP0->DRR;

}

 

The code is getting stuck at the line highlighted.

Please suggest a solution to this.

Regards,

Poornima Tom

 

 

 

 

 

 

 

 

 

 

 

 

 

  • Poornima Tom,

    DLB works fine from either the ARM side or the DSP side.

    Here a is a quick configuration just to show DLB working in my setup (I did not fully clean or followed the init procedure as this just to show the point but in a real system it is very critical to follow the mcbsp userguide as you are following) but you can compare to yours to see if you are missing something in your code.

    "void main( void )

    { Uint32 j=0, k=0, n=4, i=0;

        Uint16 errorflag    = 0;

    *(Uint32*)(0x01C14170) =  0x00000080;//ENABLE MCBSP SUSPSRC in SYSTEM CONFIG for DSP emulation suspend capability, working on 1.1 and newer silicon revision

    *(Uint32*)(0x01D10008) |= 0x00008000;//SPCR: DLB

     *(Uint32*)(0x01D1000C) = 0x00000000;//RCR: 8b, 1 word/frame

    *(Uint32*)(0x01D10010) = 0x00000000;//XCR: 8b, 1 word/frame

    *(Uint32*)(0x01D10014) = 0x20000003;//SRGR: CLKSM/SCLKME-1/0(INT), FSGM-DXRtoXSR frame, FPER-DC, FWID-DC, CLKGDV-FF

    *(Uint32*)(0x01D10024) = 0x00000E00;//PCR: FSXM-1(INT), FSRM-1(INTT), CLKXM-1(INT), CLKRM-0(driven by CLKXM in DLB)

       // Initialization of transmit values and array of received values 

    for(k=0;k<n;k++)

    {  // Initialize the array of received values to all 0s 

      rcvBuff[k] = 0; //clear receive buffer

           xmitBuff[k] = k+1; //fill in dummy data

    }

     *(Uint32*)(0x01D10008) |= 0x00400000;//SPCR: GRST-on, 

    for(j=0;j<(2*100) ;j++){}; //Wait for at least 2 CLKGs

    *(Uint32*)(0x01D10008) |= 0x00800000;//SPCR: FRST-on

    *(Uint32*)(0x01D10008) |= 0x00000001;//SPCR: RRST-on

    *(Uint32*)(0x01D10008) |= 0x00010000;//SPCR: XRST-on

    for(j=0;j<n ;j++)

    {

            // Poll for XRDY flag to acknowledge transmitter  is ready 

    while (((*(Uint32*)(0x01D10008)) & 0x00020000) != 0x00020000);

    *(Uint32*)(0x01D10004) = xmitBuff[j];//DXR write

    // Poll for RRDY flag to acknowledge receiver is ready 

    while (((*(Uint32*)(0x01D10008)) & 0x00000002) != 0x00000002);

       rcvBuff[j] = *(Uint32*)(0x01D10000); // DRR Read

        }

     

        /*

         * Compare tx and Rx Buffers

         */

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

        {

            if ( rcvBuff[i] != xmitBuff[i] )

            {

                errorflag++;

                break;

            }

        }

       /* Check for test fail */

        if ( errorflag != 0 )

        {

            /* Print error message */

            printf( "     FAIL... \n", status );

        }

        else

        {

            /* Print error message */

            printf( "    PASS\n" );

        }

    }