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.

TLV320AIC3254: Silence detection based on wifi_audio_app with CC3200

Part Number: TLV320AIC3254
Other Parts Discussed in Thread: CC3200,

I am experimenting with the Audio Boosterpack together with the CC3200 Launchpad.

I used the wifi_audio_app as a basis for a first test project.

The sample project works great, altered the code a little so it will only stream audio from a microphone to a Raspberry PI.

 

I am now looking at how I can detect silence with the AIC3254 and only stream audio when somebody speaks in the microphone, but I have some questions on how I need to set this up.

 

  • Is it possible to detect silence using another (simpler) method then setting up the AGC?

 

   I am using the mono connection on the Audio Boosterpack to connect the microphone.

AudioCodecPageSelect(TI3254_PAGE_0);

if(bitsPerSample == AUDIO_CODEC_16_BIT)
{
    // Set I2S Mode and Word Length
    AudioCodecRegWrite(0x1B, 0x00); 	                // 0x00 	16bit, I2S, BCLK is input to the device
                                                        // WCLK is input to the device,
}
else
{
    return -1;
}

bitClk = bitsPerSample * bitRate * noOfChannels;
if(bitClk == 512000) // 16 kHz - 16 bits and 2 channels
{
    AudioCodecPageSelect(TI3254_PAGE_0);

    AudioCodecRegWrite(0x04, 0x03);		                    // MCLK is input to PLL, PLL Clock is CODEC_CLKIN
    AudioCodecRegWrite(0x05, 0x94);	                        // PLL is powered up, P=1, R=4
    AudioCodecRegWrite(0x06, 0x2A);		                    // J=42
    AudioCodecRegWrite(0x07, 0x00);	                        // D = 0

    AudioCodecRegWrite(0x0B, 0x8E);		                    // NDAC divider powered up, NDAC = 14
    AudioCodecRegWrite(0x0C, 0x81);		                    // MDAC divider powered up, MDAC = 1
    AudioCodecRegWrite(0x0D, 0x01);	                        // DOSR = 0x0180 = 384
    AudioCodecRegWrite(0x0E, 0x80);	                        // DOSR = 0x0180 = 384

    AudioCodecRegWrite(0x12, 0x95);    	                    // NADC divider powered up, NADC = 21
    AudioCodecRegWrite(0x13, 0x82);                         // MADC divider powered up, MADC = 2
    AudioCodecRegWrite(0x14, 0x80);    	                    // AOSR = 128 ((Use with PRB_R1 to PRB_R6, ADC Filter Type A)
}
else
{
    return -1;
}


// Configure Power Supplies
AudioCodecPageSelect(TI3254_PAGE_1);		                //Select Page 1

AudioCodecRegWrite(0x01, 0x08);	                            // Disabled weak connection of AVDD with DVDD
AudioCodecRegWrite(0x02, 0x00);	                            // LDO Control
AudioCodecRegWrite(0x47, 0x32);                             // Analog inputs power up time is 6.4 ms
AudioCodecRegWrite(0x7B, 0x01);	                            // Reference will power up in 40ms when analog blocks are powered up

// Configure INT
AudioCodecPageSelect(TI3254_PAGE_0);                        // Select Page 0
AudioCodecRegWrite(0x30, 0x10);                             // Enable AGC Threshold INT


if(mic)
{
    unsigned char reg1 = 0x00;	                            // TI3254_MICBIAS_CTRL_REG
    unsigned char reg2 = 0x00;	                            // TI3254_LEFT_MICPGA_P_CTRL_REG
    unsigned char reg3 = 0x00;	                            // TI3254_LEFT_MICPGA_N_CTRL_REG
    unsigned char reg4 = 0x00;	                            // TI3254_RIGHT_MICPGA_P_CTRL_REG
    unsigned char reg5 = 0x00;	                            // TI3254_RIGHT_MICPGA_N_CTRL_REG
    unsigned char reg6 = 0x00;	                            // TI3254_FLOAT_IP_CTRL_REG


    AudioCodecPageSelect(TI3254_PAGE_8);	                // Select Page 8
    AudioCodecRegWrite(0x01, 0x04);                         // Adaptive Filtering enabled for ADC

    AudioCodecPageSelect(TI3254_PAGE_0);		            //Select Page 0
    AudioCodecRegWrite(0x3D, 0x2);	                        // ADC Signal Processing Block PRB_P2

    if(mic & AUDIO_CODEC_MIC_MONO)
    {
        reg1 |= 0x40;	                                    // MICBIAS powered up
        reg2 |= 0x00;
        reg3 |= 0x10;
        reg4 |= 0x10;	                                    // IN2R is routed to Right MICPGA with 10k resistance
        reg5 |= 0x40;	                                    // CM is routed to Right MICPGA via CM1R with 10k resistance
        reg6 |= 0x10;	                                    // IN2R input is weakly driven to common mode. Use when not routing IN2R to Left and Right MICPGA
    }

    AudioCodecPageSelect(TI3254_PAGE_1);     //Select Page 1

    AudioCodecRegWrite(0x33, reg1);

    //Route IN2L not routed
    AudioCodecRegWrite(0x34, reg2);

    //Route IN2R CM1L to LEFT_N with 10K input impedance
    AudioCodecRegWrite(0x36, reg3);

    //Route IN2R to RIGHT_P with 10K input impedance
    AudioCodecRegWrite(0x37, reg4);

    //Route CM1R to RIGHT_M with 10K input impedance
    AudioCodecRegWrite(0x39, reg5);

    AudioCodecRegWrite(0x3a, reg6);


    //make channel gain 0dB, since 20K input
    //impedance is used single ended
    AudioCodecRegWrite(0x3B, 0x00);	                            // 0.0dB

    //Unmute Right MICPGA, Gain selection of 6dB to
    //make channel gain 0dB, since 20K input
    //impedance is used single ended
    AudioCodecRegWrite(0x3C, 0x00);	                            // 0.0dB


    //AudioCodecRegWrite(TI3254_LEFT_ADC_VOL_CTRL_REG, 0x68);   // -12dB
    AudioCodecRegWrite(0x54, 0x68);	// -12dB


    AudioCodecPageSelect(TI3254_PAGE_0);	                    // Select Page 0

    // Configure INT
    AudioCodecRegWrite(0x30, 0x10);                             // Enable AGC Threshold INT

    // Configure AGC
    AudioCodecRegWrite(0x5E, 0xC2);                             // AGC enabled, Target level -14dB - Hysteresis +1.0dB
    AudioCodecRegWrite(0x5F, 0x64);                             // Hysteresis 2 dB - Noise Threshold -64 dB
    AudioCodecRegWrite(0x60, 0x2E);                             // Gain setting
    AudioCodecRegWrite(0x61, 0x50);                             // Attack time
    AudioCodecRegWrite(0x62, 0x00);                             // Decay time
    AudioCodecRegWrite(0x63, 0x0C);                             // Noise Debounce time 2 * 4096 ADC words
    AudioCodecRegWrite(0x64, 0x09);                             // Signal debounce time 1024 ADC words

    //Power up LADC/RADC
    AudioCodecRegWrite(0x51, 0xC0);                             // Left and Right Channel ADC is powered up

    //Unmute LADC/RADC
    AudioCodecRegWrite(0x52, 0x00);	                            // Left and Right ADC Channel Un-muted. Left and Right ADC Channel Fine Gain = 0dB,
}

And poll function wich get called in the microphone routine.

unsigned char IsNoiseFlagSet()
{
    long lRetVal = -1;

    AudioCodecPageSelect(TI3254_PAGE_0);    // Select Page 0

    // Poll threshold flag 
    unsigned char ucData[2];
    ucData[0] = 0;
    ucData[1] = 0;
    lRetVal = AudioCodecRegRead(TI3254_INT_FLAG_2_REG, &ucData[0]);
    if(lRetVal < 0)
    {
        UART_PRINT("Unable to read Audio Code register\n\r");
        MAP_UtilsDelay(3000);
    }
    MAP_UtilsDelay(6000);
    UART_PRINT("**Register value 0x2F: %d \n\r", ucData[0]);

    return (ucData[0] >> 5) & 0x01;
}

  • Whats the best approach when silence is detected, can I switch off the ADC conversion? Can I still detect noise to switch it back on in this case?

Thanks in advance.

Marcel

  • Hi, Marcel,

    Welcome to E2E and thank you for your interest in our products!

    The TLV320AIC3254 only can detect silence with the AGC noise threshold. This AGC noise threshold has a indicator flag which can be selected by the interrupt pins. Unfortunately, this AGC noise threshold function cannot disable the ADC blocks when silence is detected. So, the ADC and AGC blocks would be active all the time.

    So, you would only need to configure the interrupt function, AGC parameters and AGC noise threshold in the correct range according to your application.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hello Luis,

    Thanks for the answer.

    But I used the code above and the flag is never set, I have set the interrupt enable flag in register 0x30 (INT1 Interrupt for AGC Noise Interrupt) but for some reason when I read register 0x2E with the function above (IsNoiseFlagSet()) the flag is always zero.

    In the code above I read register 0x2E but I already corrected that in code to 0x2F, but both registers are always zero when I read them?

    I played a little with the configuration (Maximum gain and the nosie threshold) but I keep getting a zero back?

    Can you tell me whats wrong with my configuration?

    Thanks,

    Marcel

  • Hi, Marcel,

    Could you try with the following configuration?

    Could you increase the target gain from -14dB to -5.5dB (max target gain)? Then, could you modify the noise threshold from -60dB to -30dB? If the problem persists, could you try reducing the max gain in 5dB steps? All these steps should ensure that the noise threshold is good enough the reduce enable the flag in silence.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hello Luis,

    Thanks for your answer.
    I tried your approach and I programmed a great number of different configurations but for some reason the flag stays zero?
    What else can I do to make this work?

    Regards,

    Marcel
  • Hi, Marcel,

    I think that the problem could be the register that you are reading for detection. I would recommend to read Page 0 / Register 47 / Bits D5-D6. These bits are set when signal is below the noise threshold. It should be set in silence environments.

    Could you try with this register, please?

    Let me know if the problem persists.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hi Luis,

    I tried al lot of different configurations, but the problem persists?

    I checked the register and I am reading register 0x2F, when I read 0x30 the programmed 0x10 is read, so the read function seems to work.

    Is it possible to send you the project files in a PM?

    Regards,

    Marcel

  • Hi, Marcel,

    Yes, you may attach the files to this E2E thread or you may send me an E2E private message with the files.

    I will take a look at them to have a better approach to this issue.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hello Luis,

    I suppose I need to connect to you first to be able to send you a private message?

    Just send you a friend request.

    Regards,

    Marcel

  • Hi, Marcel,

    That's right. I accepted the friend request. You should be able to send me a private message now.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hi marcel_12

    I am trying to interface tlv320aic3254 with raspberry pi.
    Can you please help me ..?
    How you made connections using CC3200 and raspberry pi , tlv320aic3254..?

    I will be greatful if you help me...

    Thanks,
    Shrikant

  • Hi Shrikant,

    Dont know exactly how you want to interface from the codec to the PI. But if you use the CC3200 to stream to the PI then you can easily write a python script to open a socket on the PI and receive the audio or send audio.

    If you use the wifi_audio_app as a base then you will need mDNS support on the PI for that, you can use avahi for that.

    You will need to publish a service on the PI with the same name as the mDNS service that the wifi_audio_app uses. And use the same port to open on the PI as the example uses.

    The CC3200 will then automatically connect to the PI and you can stream to it or vice versa.

    Hope this helps.

    Marcel

  • Hi marcel,

    Thanks for your reply.

    I want to interface evaluation board of TLV320AIC3254 with raspberry pi.

    How can i connect directly evaluation board of TLV320AIC3254?

    For CC3200 approach, How to connect CC3200 to TLV320AIC3254 ?  Does TI support available on this..?

    Thanks,

    Shrikant