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.

how to read 32 bit data from TMS320C6713 from mic in ?

hi 

I have connected microphone to tms320c6713. I am unable to get 32 bit data from MCBSP (i am geting 16bit 2 complement no.) I am stuck as I want to read 32 bit data from microphone and divide it into two 16 bit no( left and right), to read the data i am using  " while (!DSK6713_AIC23_read(hCodec, &IN_L))" . hCodec = DSK6713_AIC23_openCodec(0, &config); and  Uint32 IN_L .

thanks

nageshwar 

  • Hi,

    Thanks for your post.

    As per my knowledge, the McBSP receiver in c6713 is configured to input 24 bits of data and the FSX/CLKX appear to be programmed to output 12 bits of data for a word and so, we need to check the feasibility of reading 32 bit data from mic. and divide it into two 16-bit data , but still, we need to ensure if we can program the configuration accordingly to support receiver input of 32-bit data and FSX/CLKX to transfer 32 bit via McBSP.

    You must set XDATDLY=RDATDLY=1.  You must also set FSGM=0.  These requirements are stated in Section 9.1 of the McBSP Reference Guide.  Please review the information carefully.

    http://www.ti.com/lit/ug/spru580g/spru580g.pdf

    Thanks & regards,

    Sivaraj K

    ----------------------------------------------------------------------------------------------------------------

    Please click the "Verify Answer" button on this post if it answers your question.

    ----------------------------------------------------------------------------------------------------------------

  • Nageshwar,

    There should be in the BSL example folder a stereo example that shows how to read the left and right channels. If you cannot find it there, you should be able to find a DSK6713-based training set on the TI Wiki - search TI.com for "C6713 workshop" (no quotes).

    In the example code you were using in your other thread, there were two calls to DSK6713_AIC23_write, one for OUT_L and one for OUT_R. I do not have the BSL files, but I would expect you would do the same to read two channels, two calls to DSK6713_AIC23_read, one for IN_L and one for IN_R. It should be worth a try.

    Regards,
    RandyP
  • hello Sivaraj

    Thank you for your reply , code used is described below . I tried to change the Mcbsp configuration and now the program can't go beyond "while(!DSK6713_AIC23_read(hCodec, &IN_L));" unable to read i guess.  

    #define CHIP_6713

    #include <stdio.h>
    #include <c6x.h>
    #include <csl.h>
    #include <csl_mcbsp.h>
    #include <csl_irq.h>

    #include "dsk6713.h"
    #include "dsk6713_aic23.h"

    DSK6713_AIC23_CodecHandle hCodec;

    // Codec configuration settings
    DSK6713_AIC23_Config config = { \
    0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \
    0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\
    0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */ \
    0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */ \
    0x0010, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */ \
    0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */ \
    0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */ \
    0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */ \
    0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */ \
    0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
    };

    MCBSP_Config mcbspConfig = { 0x00010000, // SPCR is set for transmitting
    0x000100A0, // 1-phase 32bit word for RCR
    0x000100A0, // 1-phase 32bit word for XCR
    0x00000000, // SRGR (Sample rate generator register FSGM)
    0x00000000,
    0x00000000,
    0x00000000,
    0x00000000,
    };
    // Int16 buf[1024];
    // Uint32 i=0;
    //interrupt void serialPortRcvISR(void);
    //void hook_int();
    //int volumeGain;

    void main()
    {
    DSK6713_AIC23_CodecHandle hCodec;
    Int16 OUT_L, OUT_R;
    Uint32 IN_L;//var2=0XFFFF0000;
    short a;
    float d_n=0.0;
    // Int16 var1=0xFFFF;
    // Int16 ans1,ans2;
    // Initialize BSL
    //int i=0;


    //intr_reset();
    DSK6713_init();


    //Start codec
    hCodec = DSK6713_AIC23_openCodec(0, &config);

    /*
    MCBSP_FSETS(SPCR2, RINTM, FRM);
    MCBSP_FSETS(SPCR2, XINTM, FRM);
    MCBSP_FSETS(RCR2, RWLEN1, 32BIT);
    MCBSP_FSETS(XCR2, XWDLEN1, 32BIT);
    */
    // Set frequency to 16KHz
    DSK6713_AIC23_setFreq(hCodec,DSK6713_AIC23_FREQ_8KHZ);
    extern far MCBSP_Handle DSK6713_AIC23_DATAHANDLE;
    MCBSP_config( DSK6713_AIC23_DATAHANDLE, &mcbspConfig );
    MCBSP_start( DSK6713_AIC23_DATAHANDLE, MCBSP_XMIT_START |
    MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC , 220 );
    for(;;)
    {
    // Read sample from the left channel


    while(!DSK6713_AIC23_read(hCodec, &IN_L));


    a=IN_L;

    d_n = (double)((double)(a)/(32768.0)); // 2^14


    OUT_L = (Int16)(d_n*32768.0); //2^15;
    OUT_R = (Int16)(d_n*32768.0); //2^15;
    //OUT_L = IN_L;
    //OUT_R = IN_L;

    // Send sample, first left next right channel
    while (!DSK6713_AIC23_write(hCodec, IN_L));
    while (!DSK6713_AIC23_write(hCodec, OUT_R));

    }
    DSK6713_AIC23_closeCodec(hCodec); // Codec close is unreachable

    }

    Nageshwar

  • RandyP

    Thanks I tried my program with two calls for DSK6713_AIC23_read now its almost perfect . If I am giving a stereo audio data input to line in (left channel with random data and right channel with zeros or no data) .

    The output while observing in CCSv5.5 has almost perfect left channel and a little residual data in right channel.(there is a lot of difference in there amplitudes but right channel not zero).

    I guess there might be a problem in data read as the data read is more than 16 bits per DSK6713_AIC23_read ( in the 2nd post Sivaraj K said its reading default 24 bits per read). Is there a simple solution to read 16 bits ..?

    thanks again for the help i am stuck at this point for days now...

    Nageshwar