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 take input form mic ?

Other Parts Discussed in Thread: TLV320AIC3106, TLV320AIC23B

The example program listed below takes input from line in and send back the same to line out. What I am willing is to take input from MIC and do the rest same. What change should I make. I am newbie to the dsp6713 & not following Rulph chassing for some reason.

/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) DSP/BIOS 4.90.270 01-08-04 (bios,dsk6713-c04)" */
/* 
 *  ======== tsk_audio.c ========
 * 
 *  This example demonstrates the use of IOM drivers with SIOs and tasks by 
 *  using the DIO class driver with a user defined device mini-driver 
 *  called "codec" and a class driver DIO instance called "dio_codec". This is 
 *  the loopback application where audio is read from an input SIO, then sent 
 *  back via an output SIO.

 *  The following objects need to be created in the DSP/BIOS
 *  configuration for this application:
 *
 *  * A UDEV object, which links in a user device driver. In this
 *    case the UDEV is a codec based IOM device driver.
 *  * A DIO object, which links the UDEV object.
 *  * A TSK object, with the function to run set to the function echo
 *    defined in this file.
 *  * A LOG named trace for debug and status output.
 */

#include <std.h>
#include <math.h>
#include <log.h>
#include <sys.h>
#include <mem.h>
#include <sio.h>

#ifdef _6x_
extern far LOG_Obj trace;
extern anc_asm_func();

/* 
 * Buffers placed in external memory are aligned on a 128 bytes boundary.
 * In addition, the buffer should be of a size multiple of 128 bytes for 
 * the cache work optimally on the C6x.
 */
#define BUFLEN 128      /* number of samples in the frame */
#define BUFALIGN 128    /* alignment of buffer to allow use of L2 cache */
#else
extern LOG_Obj trace;
#define BUFLEN 128      /* number of samples in the frame */
#define BUFALIGN 1
#endif

#define BUFSIZE (BUFLEN * sizeof(MdUns)) 

/* inStream and outStream are SIO handles created in main */
SIO_Handle inStream, outStream;

/* Function prototype */
static Void createStreams();
static Void prime();

/*
 * ======== main ========
 */
Void main()
{
	int i;
    LOG_printf(&trace, "tsk_audio started");
	
}

/*
 * ======== createStreams ========
 */
static Void createStreams()
{
    SIO_Attrs attrs;
    
    /* align the buffer to allow it to be used with L2 cache */
    attrs = SIO_ATTRS;
    attrs.align = BUFALIGN;
    attrs.model = SIO_ISSUERECLAIM;

    /* open the I/O streams */
    inStream = SIO_create("/dioCodec", SIO_INPUT, BUFSIZE, &attrs);
    if (inStream == NULL) {
        SYS_abort("Create input stream FAILED.");
    }

    outStream = SIO_create("/dioCodec", SIO_OUTPUT, BUFSIZE, &attrs);
    if (outStream == NULL) {
        SYS_abort("Create output stream FAILED.");
    }
}

/*
 * ======== prime ========
 */
static Void prime()
{
    Ptr buf0, buf1, buf2, buf3;

    LOG_printf(&trace, "Allocate buffers started");

    /* Allocate buffers for the SIO buffer exchanges */
    buf0 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
    buf1 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
    buf2 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
    buf3 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
    if (buf0 == NULL || buf1 == NULL || buf2 == NULL || buf3 == NULL) {
        SYS_abort("MEM_calloc failed.");
    } 
    
    /* Issue the first & second empty buffers to the input stream */
    if (SIO_issue(inStream, buf0, SIO_bufsize(inStream), NULL) != SYS_OK) {
        SYS_abort("Error issuing buffer to the input stream");
    }
    if (SIO_issue(inStream, buf1, SIO_bufsize(inStream), NULL) != SYS_OK) {
        SYS_abort("Error issuing buffer to the input stream");
    }

    /* Issue the first & second empty buffers to the output stream */
    if (SIO_issue(outStream, buf2, SIO_bufsize(outStream), NULL) != SYS_OK) {
        SYS_abort("Error issuing buffer to the output stream");
    }
    if (SIO_issue(outStream, buf3, SIO_bufsize(outStream), NULL) != SYS_OK) {
        SYS_abort("Error issuing buffer to the output stream");
    }
}

/*
 * ======== echo ========
 * This function copies from the input SIO to the output SIO. You could
 * easily replace the copy function with a signal processing algorithm. 
 */
Void echo()
{
    Int i;
    Int nmadus;         /* number of minimal addressable units */
    MdUns *inbuf, *outbuf;

    /* Call createStream function to create I/O streams */
    createStreams();
    
    /* Call prime function to do priming */
    prime();

    /* Loop forever looping back buffers */
    for (;;) {
        /* Reclaim full buffer from the input stream */
        if ((nmadus = SIO_reclaim(inStream, (Ptr *)&inbuf, NULL)) < 0) {
            SYS_abort("Error reclaiming full buffer from the input stream");
        }

        /* Reclaim empty buffer from the output stream to be reused */
        if (SIO_reclaim(outStream, (Ptr *)&outbuf, NULL) < 0) {
            SYS_abort("Error reclaiming empty buffer from the output stream");
        }

        /* Do the data move. */
        for (i = 0; i < (nmadus / sizeof(short)); i++) {
			
				outbuf[i] = inbuf[i];
        }

        /* Issue full buffer to the output stream */
        if (SIO_issue(outStream, outbuf, nmadus, NULL) != SYS_OK) {
            SYS_abort("Error issuing full buffer to the output stream");
        }

        /* Issue an empty buffer to the input stream */
        if (SIO_issue(inStream, inbuf, SIO_bufsize(inStream), NULL) != SYS_OK) {
            SYS_abort("Error issuing empty buffer to the input stream");
        }
    }
}

/*
 *  ======== prd10secs ========
 *  prd10secs is configured to be called every 10 seconds
 */
Void prd10secs()
{
    static Int seconds = 0;
    static Int minutes = 0;
    static Int hours = 0;

    seconds += 10;

    if (seconds == 60) {
        seconds = 0;
        minutes++;
        if (minutes == 60) {
            minutes = 0;
            hours++;
        }
        LOG_printf(&trace, "%d hours and %d minutes", hours, minutes);
    }
    else {
        LOG_printf(&trace, "%d seconds", seconds);
    }
}

  • Hi Manish,

    Thanks for your post.

    I think, you need to configure the AIC3106 codec control registers in the code to enable MIC IN support and it is feasible only if you control analog/digital microphone functionality thru. codec control registers.

    For more details, please refer the control registers details from the TLV320AIC3106 codec datasheet below:

    http://datasheet.octopart.com/TLV320AIC3106IRGZT-Texas-Instruments-datasheet-14438149.pdf

    From the above doc., please look into the following registers from the datasheet & configure the same whichever is applicable to the code and kindly validate the same.

    Page 0 / Register 8: Audio Serial Data Interface Control Register A (D0 ,D1 bits)

    Page 0 / Register 13: Headset / Button Press Detection Register A (D5, D6 bits)

    Page 0 / Register 17: MIC3L/R to Left ADC Control Register ( D0 - D7 bits)

    Page 0 / Register 18: MIC3L/R to Right ADC Control Register (D0 -D7 bits )

    Page 0 / Register 25: MICBIAS Control Register (D4 - D7 bits)

    Page 0 / Register 98: GPIO1 Control Register (D4 - D7 bits; 1010: GPIO1 output = digital microphone modulator clock)

    Page 0 / Register 99: GPIO2 Control Register (D4 -D7 bits; 0101–0111: GPIO2 input = digital microphone input, data sampled on clock rising and falling edges)

    Page 0 / Register 107: New Programmable ADC Digital Path and I2C Bus Condition Register (D4, D5 bits)

    Thanks & regards,

    Sivaraj K

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

  • Is it for c6713 as well ?

  • Hi Manish,

    I apologise that, I didn't notice that, it is c6713, It should be TLV320AIC23B codec and it has its own register map in its codec datamanual.

    http://www.ti.com/lit/ds/symlink/tlv320aic23b.pdf

    In the above doc., please check the register details (page no. 21)

    Analog Audio Path Control (Address: 0000100) , in which kindly check D2(INSEL), D1 (MICM) & D0 (MICB). By default, MICM would be muted (set to 1), so change it to normal (set to 0) and again MICB set it to 1. Also, please ensure to select the ADC input to Microphone which needs to be set to 1 and by default, input select for ADC would be line input (0)

    INSEL Input select for ADC 0 = Line 1 = Microphone

    Also, please check the register Power Down Control (Address: 0000110), D1 bit needs to be enabled   which is the MIC Microphone input 0 = On 1 = Off. By default, it is set to Off (1) and need to turn On (0).

    Kindly take care the above manipulations and configure the codec registers accordingly in the code.

    Please refer Section 3.2.2 in the above mentioned oodec datamanual document for more details on microphone input circuitry. Also refer Section 3.2.6 for sidetone insertion mode and usually, the TLV320AIC23B codec has a sidetone insertion mode where the microphone input is routed to the line and headphone outputs.

    Thanks & regards,

    Sivaraj K

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

     

     

  • Thanks you.

    But how to change that value and in which file. I am complete newbie to dsp. 

  • Hi Manish,

    Thanks for your update.

    Except codec register configuration, all others remain same. To configure codec control registers which was mentioned above in my previous post to meet your requirement, you need to review the AIC23 codec data manual for more information on the registers which needs to be manipulated for microphone input selection for the ADC.

    By the way, you need to modify your code to be configured for MICIN selection thru. AIC23 codec control registers.

    Thanks & regards,

    Sivaraj K

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

     

  • Thanks.
    I understand , I need to enable MIC In register, But question is how and in which file ? Here is an screen shot of my project. I went through all files but didn't help.

    Also when I google , every solution ends up with rulph chassing which is not helpful in my case. I know my solution lies in a single line code. Can you please write the one line for me without using any standard library keeping in mind that I have started with dsp example module tsk_audio given my TI itself. I am pretty screwed up here.