atomic14/esp32_wireless_microphone

I try to use adc atten

Opened this issue · 1 comments

void ADCSampler::configureI2S()
{
    //init ADC pad
    i2s_set_adc_mode(m_adcUnit, m_adcChannel);
    **adc1_config_channel_atten(ADC1_CHANNEL_7, ADC_ATTEN_DB_11);**
    // enable the adc
    i2s_adc_enable(m_i2sPort);
}
int ADCSampler::read(int16_t *samples, int count)
{
    // read from i2s
    size_t bytes_read = 0;
    i2s_read(m_i2sPort, samples, sizeof(int16_t) * count, &bytes_read, portMAX_DELAY);
    int samples_read = bytes_read / sizeof(int16_t);
    for (int i = 0; i < samples_read; i++)
    {
        //Serial.println(samples[i]);
        **Serial.println(uint16_t(samples[i]) & 0xfff);**
        //Serial.println(2048 - (uint16_t(samples[i]) & 0xfff));
        samples[i] = (2048 - (uint16_t(samples[i]) & 0xfff)) * 17;
    }
    return samples_read;
}

I add some code between ** **
whatever i use ADC_ATTEN_DB_11 or ADC_ATTEN_DB_0,the max nums out of serial were always about 3000 after the big loud voice was happend . Did I set it up incorrectly thanks

I don't think you can combine adc1_config_channel_atten with I2S reading the ADC.