ESP32-S3使用DMA访问ADC提示ADC bitwidth not supported

gaotao
Posts: 1
Joined: Thu Jun 02, 2022 6:09 am

ESP32-S3使用DMA访问ADC提示ADC bitwidth not supported

Postby gaotao » Thu Jun 02, 2022 6:17 am

今天在使用ESP32-S3的ADC时,需要高速ADC采样,参考example中的持续采样代码设定了ADC,调用adc_digi_controller_configure(&digi_cfg)提示ADC bitwidth not supported。
调用部分代码如下:
[Codebox]
void ESP32ADC::setHighSpeedADC()
{
// adc_digi初始化

// controller初始化
adc_digi_init_config_t adc_dma_config = {
.max_store_buf_size = 1024,
.conv_num_each_intr = 256,
.adc1_chan_mask = 0,
.adc2_chan_mask = 0
};
uint32_t freq = US_PER_S / _period_us;
serialLog.log(ESP32LogLevel::Info,"freq:%d",freq);
adc_digi_pattern_config_t adc_pattern[SOC_ADC_PATT_LEN_MAX] = {0};
uint8_t channel1 = ADC_CHANNEL_3;
uint8_t channel2 = ADC_CHANNEL_4;
adc_dma_config.adc1_chan_mask |= BIT(channel1);
uint8_t activeEADC = getActiveEADCChannel() == ECG_ADC_CHANNEL ? ADC_CHANNEL_3 : ADC_CHANNEL_5;
adc_dma_config.adc1_chan_mask |= BIT(channel2);
adc_pattern[0] = {
.atten = ADC_ATTEN_DB_11,
.channel = channel1,
.unit = ADC_UNIT_1,
.bit_width = ADC_WIDTH_12Bit
};
adc_pattern[1] = {
.atten = ADC_ATTEN_DB_11,
.channel = channel2,
.unit = ADC_UNIT_1,
.bit_width = ADC_WIDTH_12Bit
};
adc_digi_configuration_t digi_cfg = {
.conv_limit_en = false,
.conv_limit_num = 512,
.pattern_num = 2,
.sample_freq_hz = freq, //换算成采样频率
.conv_mode = ADC_CONV_SINGLE_UNIT_1, // 只使用ADC1
.format = ADC_DIGI_OUTPUT_FORMAT_TYPE2
};
digi_cfg.adc_pattern = adc_pattern;
ESP_ERROR_CHECK(adc_digi_initialize(&adc_dma_config));
ESP_ERROR_CHECK(adc_digi_controller_configure(&digi_cfg));
}
[/Codebox]

请问,以上使用方法是否有问题?
详细是错误输出为:
E (37732) ADC: adc_digi_controller_configure(571): ADC bitwidth not supported
ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x4037d7f8
file: "src/ESP32ADC.cpp" line 108
func: void ESP32ADC::setHighSpeedADC()
expression: adc_digi_controller_configure(&digi_cfg)

abort() was called at PC 0x4037d7fb on core 0


Backtrace:0x4037768e:0x3fcb6c300x4037d805:0x3fcb6c50 0x40382f0d:0x3fcb6c70 0x4037d7fb:0x3fcb6cf0 0x42005af4:0x3fcb6d10 0x42005fcf:0x3fcb6dc0 0x4200330b:0x3fcb6de0 0x42003c11:0x3fcb6e00 0x42005331:0x3fcb6e60 0x42005340:0x3fcb6e90

ESP_Yake
Posts: 109
Joined: Mon Mar 06, 2017 12:23 pm

Re: ESP32-S3使用DMA访问ADC提示ADC bitwidth not supported

Postby ESP_Yake » Mon Jun 06, 2022 1:32 am

提示已经很明显了。是宽度设置为 12 不支持的,你可以改成13再试一下

Who is online

Users browsing this forum: No registered users and 61 guests