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

jiangteng
Posts: 25
Joined: Wed Jan 30, 2019 7:08 am

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

Postby jiangteng » Tue Jun 13, 2023 8:14 am

产品采用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()重启也无法恢复。

ESP_Bob
Posts: 80
Joined: Fri Nov 27, 2020 12:52 pm

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

Postby ESP_Bob » Tue Jul 18, 2023 9:36 am

尝试在 esp_restart 之前去初始化 ADC 和 DMA 驱动,并且尝试 adc_power_off。
因为 esp_restart 是内核复位,可能 ADC 状态机未正常恢复

Who is online

Users browsing this forum: No registered users and 37 guests