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 following configuration based on another topic about silence detection (https://e2e.ti.com/support/data_converters/audio_converters/f/64/t/524690) to setup the AIC3254, and poll the INT1 flag (register 0x2E ) in the microphone routine, but the INT1 flag is never set?
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