I2S ADC1 return zero buffer when WiFi on

Mikhail Khalizev
Posts: 3
Joined: Mon Oct 21, 2019 12:45 am

I2S ADC1 return zero buffer when WiFi on

Postby Mikhail Khalizev » Thu Nov 14, 2019 9:13 pm

Hi.

I am writing a simple oscilloscope that captures a signal through I2S ADC1 and sends it via WiFi.

And I came across a problem. When WiFi is off, the I2S ADC1 is working correctly.
But when WiFi is turned on, I2S starts to return a buffer consisting of only 0.

And this is completely wrong, if only because the high 4 bits of the sample contain the channel number from which ADC1 is captured. And since I use ADC1_CHANNEL_6, the returned data, in principle, cannot be equal to 0 under any conditions.

I can not understand why I2S returns zero buffer. Please, help.


Part of code that read data from i2s and check it:

Code: Select all

    {
        ...
        
        std::vector<uint16_t> samples;
        samples.resize(2048);

        size_t bytes_read;
        status = i2s_read(I2S_NUM_0, samples.data(), samples.size() * sizeof(uint16_t), &bytes_read, 100 / portTICK_PERIOD_MS);
        ESP_ERROR_CHECK(status);
        samples.resize(bytes_read / 2);

        if (contains_only_zeros(samples))
            ESP_LOGE("adc_test", "iteration: %d, samples count: %d, all zeros", iteration, samples.size());
        else
            ESP_LOGI("adc_test", "iteration: %d, samples count: %d, ok", iteration, samples.size());
            
        ...
    }

    bool contains_only_zeros(std::vector<uint16_t>& samples)
    {
        for (auto sample : samples)
            if (sample != 0)
                return false;
        return true;
    }
short log:

Code: Select all

I (3676) adc_test: iteration: 1, samples count: 2048, ok
I (4706) adc_test: iteration: 2, samples count: 2048, ok
I (5736) adc_test: iteration: 3, samples count: 2048, ok
I (6766) adc_test: iteration: 4, samples count: 2048, ok
I (7799) adc_test: iteration: 5, samples count: 2048, ok
E (8829) adc_test: iteration: 6, samples count: 2048, all zeros
E (9859) adc_test: iteration: 7, samples count: 2048, all zeros
E (10891) adc_test: iteration: 8, samples count: 2048, all zeros
E (11923) adc_test: iteration: 9, samples count: 2048, all zeros
E (12955) adc_test: iteration: 10, samples count: 2048, all zeros
E (13986) adc_test: iteration: 11, samples count: 2048, all zeros
E (15017) adc_test: iteration: 12, samples count: 2048, all zeros
E (16048) adc_test: iteration: 13, samples count: 2048, all zeros
E (17080) adc_test: iteration: 14, samples count: 2048, all zeros
E (18111) adc_test: iteration: 15, samples count: 2048, all zeros
E (19142) adc_test: iteration: 16, samples count: 2048, all zeros

I'm using last branch 'release/v3.3' from 'esp-idf' repo.

full source code to reproduce:
main.cpp
(2.84 KiB) Downloaded 12 times

sdkconfig:
sdkconfig.txt
(22.37 KiB) Downloaded 18 times

full log:
log.txt
(11.39 KiB) Downloaded 21 times

Who is online

Users browsing this forum: MSN [Bot] and 19 guests