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.

audio code doubt

Other Parts Discussed in Thread: PCM3002, TMS320VC5416

 

 

 

 

 

 

 

 

 

void

CodecRead()

{

DSK5416_PCM3002_CodecHandle hCodec;

hCodec = DSK5416_PCM3002_openCodec(0,&Config);

 

 

for (sample = 0; sample < SINE_TABLE_SIZE; sample++)

{

 

 

/* read a sample from the Codec channel */

 

 

while(!DSK5416_PCM3002_read16(hCodec, &SpeechInput[sample]));

 

 

 

/*storing in the input buffer */

 

 

//sinetable[sample]=input;

 

 

/* Send a sample to the left channel */

 

 

while (!DSK5416_PCM3002_write16(hCodec,SpeechInput[sample]));

 

 

/* Send a sample to the right channel */

 

 

while (!DSK5416_PCM3002_write16(hCodec,SpeechInput[sample]));

}

DSK5416_PCM3002_closeCodec(hCodec);

 

This is part of a code I'm trying to understand. What its doing here is taking audio samples and sending it into the headphone output. But I have a few doubts.

1. how can the same line of code send a signal to a right channel and left channel audio output just because it is written twice?

/* Send a sample to the left channel */

 

 

 

while (!DSK5416_PCM3002_write16(hCodec,SpeechInput[sample]));

 

 

/* Send a sample to the right channel */

 

 

 

while (!DSK5416_PCM3002_write16(hCodec,SpeechInput[sample]));

2. DSK5416_PCM3002_CodecHandle hCodec- what does this command imply?

 

Thanks in advance. 

  • Naveen,

    I have a couple of questions for you.  Can you show the configuration of the McBSP.  Also, what is the McBSP interfaced to?

    Regards.

  • Tommy,

    I am absolutely new to using this processor. Well all I can tell you is, there is a mic and a headphone connected to the processor. How do you know that the mcbsp is used here?

  • Naveen,
    From the code snippet, it looks like you are using the Spectrum Digital (SD) TMS320VC5416 DSK.  Is this correct?  If this is correct, then you should have access to SD web site where you can download the Technical Reference Guide for the DSK.  The TRG contains schematics and details of the DSK.  This document shows that the codec is interfaced to McBSP2 on the VC5416 DSP.  Do you have access to this information?

    Where did you get the code that you reference in your original post?  Someplace in the code should be an intialization of the DSP McBSP and the PCM3002 codec. 

    I found an old application note here: http://focus.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=spra855a that describes a device driver for the PCM3002 and VC5416 that you might find useful.  Not sure without more information if this is the implementation that is being used by you, but should give you an idea of how the DSP and codec communicate.

    Regards.

  • Tommy,

    You are right, its a Spectrum Digital board. A friend of mine has written this code. I could paste whats written in the .h files here if that would give you a clearer idea.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    #define

     

    CHIP_5416 1

     

     

     

     

     

     

    /* Include Header Files */

    #include

     

    <std.h>

    #include

     

    <hst.h>

    #include

    <swi.h>

    #include

    <tsk.h>

    #include

    <log.h>

    #include

    <sts.h>

    #include

    <csl_mcbsp.h>

     

    #if def__cplusplus

     

    extern

    "C"

    {

    #endif

    extern

    HST_Obj RTA_fromHost;

    extern

    HST_Obj RTA_toHost;

    extern

    SWI_Obj KNL_swi;

    extern

    TSK_Obj TSK_idle;

    extern

    TSK_Obj CODEC;

    extern

    LOG_Obj LOG_system;

    extern

    STS_Obj IDL_busyObj;

    extern

    MCBSP_Config mcbspCfg0;

    extern

    MCBSP_Handle C54XX_DMA_MCBSP_hMcbsp;

     

    extern

    void CSL_cfgInit();

    #ifdef

    __cplusplus

    }

     

    #endif

     

    /* extern "C" */

     

     ************************************************

    This is placed in a header file called lineincfg.h

    I'd like to know one more thing. What do you think the following could mean. This part is written in the main file.

     

     

     

     

    DSK5416_PCM3002_Config Config={\

    0x0100,

     

    /* Control Register 0 on PCM3002 device */

    0x01FF,

     

    /* Control Register 1 on PCM3002 device */

    0x0002,

     

    /* Control Register 2 on PCM3002 device */

    0x0000

     

    /* Control Register 3 on PCM3002 device */

    };

     

     

    Thanks a lot.

  • I think I found the mcbsp initialization.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    #include

     

    "lineincfg.h"

    /* Config Structures */

    MCBSP_Config mcbspCfg0 = {

    0x0000,

     

    /* Serial Port Control Register 1 */

    0x0000,

     

    /* Serial Port Control Register 2 */

    0x01a0,

     

    /* Receive Control Register 1 */

    0x0000,

     

    /* Receive Control Register 2 */

    0x01a0,

     

    /* Transmit Control Register 1 */

    0x0000,

     

    /* Transmit Control Register 2 */

    0x1f00,

     

    /* Sample Rate Generator Register 1 */

    0x0000,

     

    /* Sample Rate Generator Register 2 */

    0x0000,

     

    /* Multichannel Control Register 1 */

    0x0000,

     

    /* Multichannel Control Register 2 */

    0x0083,

     

    /* Pin Control Register */

    0x0000,

     

    /* Receive Channel Enable Register Partition A */

    0x0000,

     

    /* Receive Channel Enable Register Partition B */

    0x0000,

     

    /* Receive Channel Enable Register Partition C */

    0x0000,

     

    /* Receive Channel Enable Register Partition D */

    0x0000,

     

    /* Receive Channel Enable Register Partition E */

    0x0000,

     

    /* Receive Channel Enable Register Partition F */

    0x0000,

     

    /* Receive Channel Enable Register Partition G */

    0x0000,

     

    /* Receive Channel Enable Register Partition H */

    0x0000,

     

    /* Transmit Channel Enable Register Partition A */

    0x0000,

     

    /* Transmit Channel Enable Register Partition B */

    0x0000,

     

    /* Transmit Channel Enable Register Partition C */

    0x0000,

     

    /* Transmit Channel Enable Register Partition D */

    0x0000,

     

    /* Transmit Channel Enable Register Partition E */

    0x0000,

     

    /* Transmit Channel Enable Register Partition F */

    0x0000,

     

    /* Transmit Channel Enable Register Partition G */

    0x0000

     

    /* Transmit Channel Enable Register Partition H */

    };

    /* Handles */

    MCBSP_Handle C54XX_DMA_MCBSP_hMcbsp;

    /*

    * ======== CSL_cfgInit() ========

    */

    void

     

    CSL_cfgInit()

  • Naveen,
    I would guess that the code relating to McBSP_Config would contain the details of how the serial ported is configured.  Our Reference Guide TMS320C54x DSP Reference Set: Vol 1 (http://www-s.ti.com/sc/techlit/spru131) contains the details of the operation and configuration of the serial ports on your device.

    The code you show above looks like it is to configure the PCM3002 codec on the target board.  Is that what you are asking?

    Regards.

  • Ok, that covers a lot of areas I had doubts in. Thanks a lot TI, I really appreciate this :-).