AnsweredAssumed Answered

2147x sport code

Question asked by twilkers Employee on Apr 22, 2015
Latest reply on Apr 23, 2015 by Jithul_Janardhanan

my customer has a problem with his init, can you take a look at it?  thanks, Tim

 

 

I tried to use PCG to generate clock for master I2S to transmit data.

The I2S information is as following:

        Fs 8kHz

        32bit

        Bit Clk:  8 * 64 = 512KHz

The external clock is 2.048 Mhz (256 *fs) for PCG.

 

I found the data on I2S bus (SPORT0A) are not correct. The below is my some codes for the I2S. Please to check these and find some wrong settings. Thanks.

 

 

Codes:

=====

//SRU:

    SRU(LOW, PBEN20_I); //extern clock 2.048MHz

    SRU(DAI_PB20_O, PCG_EXTA_I);

 

    SRU(HIGH, PBEN16_I);

    SRU(DAI_PB20_O, DAI_PB16_I);

 

    SRU(PCG_CLKA_O, SPORT0_CLK_I);

    SRU(PCG_FSA_O, SPORT0_FS_I);

 

    SRU (HIGH, PBEN10_I);

SRU(PCG_CLKA_O, DAI_PB10_I);

 

    SRU (HIGH, PBEN11_I);

SRU(PCG_FSA_O,  DAI_PB11_I);

 

   SRU (HIGH, PBEN12_I);

   SRU (SPORT0_DA_O, DAI_PB12_I);

 

 

//PGC init

   #define DIVCLKA             4

   #define DIVFSA                 256

 

            *pPCG_CTLA0 = 0;

            *pPCG_CTLB0 = 0;

 

            // Wait minimum 16 cycles after disable the PCG

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

                        asm("NOP;");

 

            *pPCG_CTLA1 |= DIVCLKA | CLKASOURCE  | FSASOURCE ;

            *pPCG_CTLA0 |= DIVFSA | ENFSA | ENCLKA;

 

 

//Sport0A init

 

            TCB_Block_Out0[0] = (((int) TCB_Block_Out1 + 3) & OFFSET_MASK);

            TCB_Block_Out0[3] = (unsigned int) OutBlock_0;

 

            TCB_Block_Out1[0] = (((int) TCB_Block_Out0 + 3) & OFFSET_MASK);

            TCB_Block_Out1[3] = (unsigned int) OutBlock_1;

 

            *pSPMCTL0 = 0;

            *pSPCTL0 = 0;

            *pDIV0 = 0;

           

        for(i=0;i<8;i++) asm("nop;");

 

            /* Enabling Chaining */

            /* Block A will be filled first */

            //*pCPSP0A = ((unsigned int) TCB_Block_InA + 7) & OFFSET_MASK ;

    *pCPSP0A = (unsigned int)TCB_Block_Out0 - OFFSET + 3;

 

            *pSPCTL0 = (SPEN_A|    /* Enable Channel A */

                                                SDEN_A| /* Enable Channel A DMA */

                                                SCHEN_A| /* Enable Channel A DMA Chaining */

                                                SLEN32| /* 32-bit word length */

                                                OPMODE| /* Enable I2S Mode*/

                                                MSTR| /*master mode*/

                                                SPTRAN); /* Transmit on enabled channels */

Outcomes