Page 1 of 1

esp-idf_v4.4.2 软复位有概率导致i2s adc工作不正常

Posted: Tue Jun 13, 2023 8:14 am
by jiangteng
产品采用i2s adc+dma来采集周期性的模拟信号,程序在上电启动后即对其进行初始化:

Code: Select all

esp_err_t err;
    i2s_config_t i2s_config = {
       .mode = I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_TX | I2S_MODE_ADC_BUILT_IN,
       .sample_rate =  I2S_SAMPLE_RATE,
       .bits_per_sample = I2S_SAMPLE_BITS,
       .communication_format = I2S_COMM_FORMAT_STAND_MSB,
       .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
       .intr_alloc_flags = 0,
       .dma_buf_count = 2,
       .dma_buf_len = 1024,
       .use_apll = 1,
    };
    //install and start i2s driver
    err = i2s_driver_install(I2S_NUM, &i2s_config, 0, NULL);
    ESP_LOGI("load", "init step 1: %d", err);
    vTaskDelay(2000 / portTICK_RATE_MS);
    err = i2s_set_adc_mode(I2S_ADC_UNIT, I2S_ADC_CHANNEL);
    ESP_LOGI("load", "init step 2: %d", err);
    err = i2s_adc_enable(I2S_NUM);
    ESP_LOGI("load", "init step 3: %d", err);
同时产品具有软件重启的功能,某些情况下将调用esp_restart();
经过测试,esp_restart()重启后,有一定的概率出现i2s adc读出的值一直为0,此现象将一直持续,置到esp32通过硬件复位,期间无论触发多少次esp_restart()重启也无法恢复。

Re: esp-idf_v4.4.2 软复位有概率导致i2s adc工作不正常

Posted: Tue Jul 18, 2023 9:36 am
by ESP_Bob
尝试在 esp_restart 之前去初始化 ADC 和 DMA 驱动,并且尝试 adc_power_off。
因为 esp_restart 是内核复位,可能 ADC 状态机未正常恢复