今天在使用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 ac
tiveEADC = 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