Merge branch 'bugfix/fix_wrong_adc_attenuation_name_v4.4' into 'release/v4.4'

fix(adc): rename ADC_ATTEN_DB_11 to ADC_ATTEN_DB_12 (v4.4)

See merge request espressif/esp-idf!26969
This commit is contained in:
morris 2023-11-09 10:32:16 +08:00
commit 9b2661c91c
21 changed files with 36 additions and 35 deletions

View File

@ -60,7 +60,7 @@ esp_pm_lock_handle_t adc_digi_arbiter_lock = NULL;
#define ADC_MEAS_NUM_LIM_DEFAULT (1) #define ADC_MEAS_NUM_LIM_DEFAULT (1)
#define ADC_MAX_MEAS_NUM_DEFAULT (255) #define ADC_MAX_MEAS_NUM_DEFAULT (255)
#define DIG_ADC_OUTPUT_FORMAT_DEFUALT (ADC_DIGI_FORMAT_12BIT) #define DIG_ADC_OUTPUT_FORMAT_DEFUALT (ADC_DIGI_FORMAT_12BIT)
#define DIG_ADC_ATTEN_DEFUALT (ADC_ATTEN_DB_11) #define DIG_ADC_ATTEN_DEFUALT (ADC_ATTEN_DB_12)
#define DIG_ADC_BIT_WIDTH_DEFUALT (ADC_WIDTH_BIT_12) #define DIG_ADC_BIT_WIDTH_DEFUALT (ADC_WIDTH_BIT_12)
esp_err_t adc_digi_init(void) esp_err_t adc_digi_init(void)

View File

@ -19,7 +19,7 @@ Don't put any other code into this file. */
static __attribute__((constructor)) void adc2_init_code_calibration(void) static __attribute__((constructor)) void adc2_init_code_calibration(void)
{ {
const adc_ll_num_t adc_n = ADC_NUM_2; const adc_ll_num_t adc_n = ADC_NUM_2;
const adc_atten_t atten = ADC_ATTEN_DB_11; const adc_atten_t atten = ADC_ATTEN_DB_12;
const adc_channel_t channel = 0; const adc_channel_t channel = 0;
adc_cal_offset(adc_n, channel, atten); adc_cal_offset(adc_n, channel, atten);
} }

View File

@ -19,7 +19,7 @@ Don't put any other code into this file. */
static __attribute__((constructor)) void adc2_init_code_calibration(void) static __attribute__((constructor)) void adc2_init_code_calibration(void)
{ {
const adc_ll_num_t adc_n = ADC_NUM_2; const adc_ll_num_t adc_n = ADC_NUM_2;
const adc_atten_t atten = ADC_ATTEN_DB_11; const adc_atten_t atten = ADC_ATTEN_DB_12;
const adc_channel_t channel = 0; const adc_channel_t channel = 0;
adc_cal_offset(adc_n, channel, atten); adc_cal_offset(adc_n, channel, atten);
} }

View File

@ -89,7 +89,7 @@ typedef enum {
#define ADC_ATTEN_0db ADC_ATTEN_DB_0 #define ADC_ATTEN_0db ADC_ATTEN_DB_0
#define ADC_ATTEN_2_5db ADC_ATTEN_DB_2_5 #define ADC_ATTEN_2_5db ADC_ATTEN_DB_2_5
#define ADC_ATTEN_6db ADC_ATTEN_DB_6 #define ADC_ATTEN_6db ADC_ATTEN_DB_6
#define ADC_ATTEN_11db ADC_ATTEN_DB_11 #define ADC_ATTEN_11db ADC_ATTEN_DB_12
/** /**
* The default (max) bit width of the ADC of current version. You can also get the maximum bitwidth * The default (max) bit width of the ADC of current version. You can also get the maximum bitwidth

View File

@ -161,7 +161,7 @@ TEST_CASE("test_adc_dma", "[adc][ignore][manual]")
bool print_figure; bool print_figure;
if (target_atten == ADC_ATTEN_MAX) { if (target_atten == ADC_ATTEN_MAX) {
atten = ADC_ATTEN_DB_0; atten = ADC_ATTEN_DB_0;
target_atten = ADC_ATTEN_DB_11; target_atten = ADC_ATTEN_DB_12;
print_figure = false; print_figure = false;
} else { } else {
atten = target_atten; atten = target_atten;
@ -228,7 +228,7 @@ TEST_CASE("test_adc_single", "[adc][ignore][manual]")
bool print_figure; bool print_figure;
if (target_atten == ADC_ATTEN_MAX) { if (target_atten == ADC_ATTEN_MAX) {
atten = ADC_ATTEN_DB_0; atten = ADC_ATTEN_DB_0;
target_atten = ADC_ATTEN_DB_11; target_atten = ADC_ATTEN_DB_12;
print_figure = false; print_figure = false;
} else { } else {
atten = target_atten; atten = target_atten;

View File

@ -236,7 +236,7 @@ static void i2s_adc_init(void)
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL); i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
// init ADC pad // init ADC pad
i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_4); i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_4);
// enable adc sampling, ADC_WIDTH_BIT_12, ADC_ATTEN_DB_11 hard-coded in adc_i2s_mode_init // enable adc sampling, ADC_WIDTH_BIT_12, ADC_ATTEN_DB_12 hard-coded in adc_i2s_mode_init
i2s_adc_enable(I2S_NUM_0); i2s_adc_enable(I2S_NUM_0);
} }

View File

@ -32,8 +32,8 @@ static const char *TAG = "test_adc";
#define ADC2_TEST_WIDTH ADC_WIDTH_BIT_13 //ESP32S2 only support 13 bit width #define ADC2_TEST_WIDTH ADC_WIDTH_BIT_13 //ESP32S2 only support 13 bit width
#endif #endif
#define ADC1_TEST_ATTEN ADC_ATTEN_DB_11 #define ADC1_TEST_ATTEN ADC_ATTEN_DB_12
#define ADC2_TEST_ATTEN ADC_ATTEN_DB_11 #define ADC2_TEST_ATTEN ADC_ATTEN_DB_12
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
#define ADC1_TEST_CHANNEL_NUM 8 #define ADC1_TEST_CHANNEL_NUM 8

View File

@ -30,7 +30,7 @@ static const char *TAG = "test_dac";
#elif defined CONFIG_IDF_TARGET_ESP32S2 #elif defined CONFIG_IDF_TARGET_ESP32S2
#define ADC_TEST_WIDTH ADC_WIDTH_BIT_13 //ESP32S2 only support 13 bit width #define ADC_TEST_WIDTH ADC_WIDTH_BIT_13 //ESP32S2 only support 13 bit width
#endif #endif
#define ADC_TEST_ATTEN ADC_ATTEN_DB_11 #define ADC_TEST_ATTEN ADC_ATTEN_DB_12
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
#define ADC_TEST_CHANNEL_NUM ADC2_CHANNEL_8 // GPIO25 #define ADC_TEST_CHANNEL_NUM ADC2_CHANNEL_8 // GPIO25
@ -180,8 +180,8 @@ TEST_CASE("esp32s2 adc2-dac with adc2 calibration", "[adc-dac]")
subtest_adc_dac(1250, &chars); subtest_adc_dac(1250, &chars);
printf("Test 11dB atten...\n"); printf("Test 11dB atten...\n");
adc2_config_channel_atten((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_ATTEN_DB_11); adc2_config_channel_atten((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_ATTEN_DB_12);
esp_adc_cal_characterize(ADC_UNIT_2, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_13, 0, &chars); esp_adc_cal_characterize(ADC_UNIT_2, ADC_ATTEN_DB_12, ADC_WIDTH_BIT_13, 0, &chars);
printf("a %d, b %d\n", chars.coeff_a, chars.coeff_b); printf("a %d, b %d\n", chars.coeff_a, chars.coeff_b);
subtest_adc_dac(1500, &chars); subtest_adc_dac(1500, &chars);
subtest_adc_dac(2500, &chars); subtest_adc_dac(2500, &chars);

View File

@ -769,7 +769,7 @@ TEST_CASE("I2S adc test", "[i2s]")
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL); i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
// init ADC pad // init ADC pad
i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_4); i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_4);
// enable adc sampling, ADC_WIDTH_BIT_12, ADC_ATTEN_DB_11 hard-coded in adc_i2s_mode_init // enable adc sampling, ADC_WIDTH_BIT_12, ADC_ATTEN_DB_12 hard-coded in adc_i2s_mode_init
i2s_adc_enable(I2S_NUM_0); i2s_adc_enable(I2S_NUM_0);
// init read buffer // init read buffer
uint16_t *i2sReadBuffer = (uint16_t *)calloc(1024, sizeof(uint16_t)); uint16_t *i2sReadBuffer = (uint16_t *)calloc(1024, sizeof(uint16_t));

View File

@ -319,7 +319,7 @@ esp_adc_cal_value_t esp_adc_cal_characterize(adc_unit_t adc_num,
chars->bit_width = bit_width; chars->bit_width = bit_width;
chars->vref = (EFUSE_VREF_ENABLED && efuse_vref_present) ? read_efuse_vref() : default_vref; chars->vref = (EFUSE_VREF_ENABLED && efuse_vref_present) ? read_efuse_vref() : default_vref;
//Initialize fields for lookup table if necessary //Initialize fields for lookup table if necessary
if (LUT_ENABLED && atten == ADC_ATTEN_DB_11) { if (LUT_ENABLED && atten == ADC_ATTEN_DB_12) {
chars->low_curve = (adc_num == ADC_UNIT_1) ? lut_adc1_low : lut_adc2_low; chars->low_curve = (adc_num == ADC_UNIT_1) ? lut_adc1_low : lut_adc2_low;
chars->high_curve = (adc_num == ADC_UNIT_1) ? lut_adc1_high : lut_adc2_high; chars->high_curve = (adc_num == ADC_UNIT_1) ? lut_adc1_high : lut_adc2_high;
} else { } else {
@ -339,8 +339,8 @@ uint32_t esp_adc_cal_raw_to_voltage(uint32_t adc_reading, const esp_adc_cal_char
adc_reading = ADC_12_BIT_RES - 1; //Set to 12bit res max adc_reading = ADC_12_BIT_RES - 1; //Set to 12bit res max
} }
if (LUT_ENABLED && (chars->atten == ADC_ATTEN_DB_11) && (adc_reading >= LUT_LOW_THRESH)) { //Check if in non-linear region if (LUT_ENABLED && (chars->atten == ADC_ATTEN_DB_12) && (adc_reading >= LUT_LOW_THRESH)) { //Check if in non-linear region
//Use lookup table to get voltage in non linear portion of ADC_ATTEN_DB_11 //Use lookup table to get voltage in non linear portion of ADC_ATTEN_DB_12
uint32_t lut_voltage = calculate_voltage_lut(adc_reading, chars->vref, chars->low_curve, chars->high_curve); uint32_t lut_voltage = calculate_voltage_lut(adc_reading, chars->vref, chars->low_curve, chars->high_curve);
if (adc_reading <= LUT_HIGH_THRESH) { //If ADC is transitioning from linear region to non-linear region if (adc_reading <= LUT_HIGH_THRESH) { //If ADC is transitioning from linear region to non-linear region
//Linearly interpolate between linear voltage and lut voltage //Linearly interpolate between linear voltage and lut voltage

View File

@ -74,7 +74,7 @@ static bool prepare_calib_data_for(adc_unit_t adc_num, adc_atten_t atten, adc_ca
case ADC_ATTEN_DB_6: case ADC_ATTEN_DB_6:
parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 1000; parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 1000;
break; break;
case ADC_ATTEN_DB_11: case ADC_ATTEN_DB_12:
parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 2000; parsed_data_storage->efuse_data.ver2.adc_calib_high_voltage = 2000;
break; break;
default: default:

View File

@ -799,19 +799,19 @@ static inline adc_ll_rtc_raw_data_t adc_ll_rtc_analysis_raw_data(adc_ll_num_t ad
* - 0dB attenuaton (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V * - 0dB attenuaton (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V
* - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V * - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V
* - 11dB attenuation (ADC_ATTEN_DB_11) gives full-scale voltage 3.9V (see note below) * - 12dB attenuation (ADC_ATTEN_DB_12) gives full-scale voltage 3.9V (see note below)
* *
* @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured * @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured
* bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.) * bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
* *
* @note At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage. * @note At 12dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.
* *
* Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges: * Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges:
* *
* - 0dB attenuaton (ADC_ATTEN_DB_0) between 100 and 950mV * - 0dB attenuaton (ADC_ATTEN_DB_0) between 100 and 950mV
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV
* - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV * - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV
* - 11dB attenuation (ADC_ATTEN_DB_11) between 150 to 2450mV * - 12dB attenuation (ADC_ATTEN_DB_12) between 150 to 2450mV
* *
* For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges. * For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
* *

View File

@ -1011,19 +1011,19 @@ static inline adc_ll_rtc_raw_data_t adc_ll_rtc_analysis_raw_data(adc_ll_num_t ad
* - 0dB attenuaton (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V * - 0dB attenuaton (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V
* - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V * - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V
* - 11dB attenuation (ADC_ATTEN_DB_11) gives full-scale voltage 3.9V (see note below) * - 12dB attenuation (ADC_ATTEN_DB_12) gives full-scale voltage 3.9V (see note below)
* *
* @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured * @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured
* bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.) * bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
* *
* @note At 11dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage. * @note At 12dB attenuation the maximum voltage is limited by VDD_A, not the full scale voltage.
* *
* Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges: * Due to ADC characteristics, most accurate results are obtained within the following approximate voltage ranges:
* *
* - 0dB attenuaton (ADC_ATTEN_DB_0) between 100 and 950mV * - 0dB attenuaton (ADC_ATTEN_DB_0) between 100 and 950mV
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV
* - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV * - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV
* - 11dB attenuation (ADC_ATTEN_DB_11) between 150 to 2450mV * - 12dB attenuation (ADC_ATTEN_DB_12) between 150 to 2450mV
* *
* For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges. * For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
* *

View File

@ -267,7 +267,7 @@ void adc_hal_digi_stop(adc_hal_context_t *hal);
* - 0dB attenuaton (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V * - 0dB attenuaton (ADC_ATTEN_DB_0) gives full-scale voltage 1.1V
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) gives full-scale voltage 1.5V
* - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V * - 6dB attenuation (ADC_ATTEN_DB_6) gives full-scale voltage 2.2V
* - 11dB attenuation (ADC_ATTEN_DB_11) gives full-scale voltage 3.9V (see note below) * - 11dB attenuation (ADC_ATTEN_DB_12) gives full-scale voltage 3.9V (see note below)
* *
* @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured * @note The full-scale voltage is the voltage corresponding to a maximum reading (depending on ADC1 configured
* bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.) * bit width, this value is: 4095 for 12-bits, 2047 for 11-bits, 1023 for 10-bits, 511 for 9 bits.)
@ -279,7 +279,7 @@ void adc_hal_digi_stop(adc_hal_context_t *hal);
* - 0dB attenuaton (ADC_ATTEN_DB_0) between 100 and 950mV * - 0dB attenuaton (ADC_ATTEN_DB_0) between 100 and 950mV
* - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV * - 2.5dB attenuation (ADC_ATTEN_DB_2_5) between 100 and 1250mV
* - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV * - 6dB attenuation (ADC_ATTEN_DB_6) between 150 to 1750mV
* - 11dB attenuation (ADC_ATTEN_DB_11) between 150 to 2450mV * - 11dB attenuation (ADC_ATTEN_DB_12) between 150 to 2450mV
* *
* For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges. * For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
* *

View File

@ -47,10 +47,11 @@ typedef enum {
* @brief ADC attenuation parameter. Different parameters determine the range of the ADC. See ``adc1_config_channel_atten``. * @brief ADC attenuation parameter. Different parameters determine the range of the ADC. See ``adc1_config_channel_atten``.
*/ */
typedef enum { typedef enum {
ADC_ATTEN_DB_0 = 0, /*!<No input attenumation, ADC can measure up to approx. 800 mV. */ ADC_ATTEN_DB_0 = 0, ///<No input attenuation, ADC can measure up to approx.
ADC_ATTEN_DB_2_5 = 1, /*!<The input voltage of ADC will be attenuated extending the range of measurement by about 2.5 dB (1.33 x) */ ADC_ATTEN_DB_2_5 = 1, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 2.5 dB
ADC_ATTEN_DB_6 = 2, /*!<The input voltage of ADC will be attenuated extending the range of measurement by about 6 dB (2 x) */ ADC_ATTEN_DB_6 = 2, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 6 dB
ADC_ATTEN_DB_11 = 3, /*!<The input voltage of ADC will be attenuated extending the range of measurement by about 11 dB (3.55 x) */ ADC_ATTEN_DB_12 = 3, ///<The input voltage of ADC will be attenuated extending the range of measurement by about 12 dB
ADC_ATTEN_DB_11 __attribute__((deprecated)) = ADC_ATTEN_DB_12, ///<This is deprecated, it behaves the same as `ADC_ATTEN_DB_12`
ADC_ATTEN_MAX, ADC_ATTEN_MAX,
} adc_atten_t; } adc_atten_t;

View File

@ -62,7 +62,7 @@ Attenuation Measurable input voltage range
``ADC_ATTEN_DB_0`` {IDF_TARGET_ADC_V_MIN_ATTEN0} mV ~ {IDF_TARGET_ADC_V_MAX_ATTEN0} mV ``ADC_ATTEN_DB_0`` {IDF_TARGET_ADC_V_MIN_ATTEN0} mV ~ {IDF_TARGET_ADC_V_MAX_ATTEN0} mV
``ADC_ATTEN_DB_2_5`` {IDF_TARGET_ADC_V_MIN_ATTEN1} mV ~ {IDF_TARGET_ADC_V_MAX_ATTEN1} mV ``ADC_ATTEN_DB_2_5`` {IDF_TARGET_ADC_V_MIN_ATTEN1} mV ~ {IDF_TARGET_ADC_V_MAX_ATTEN1} mV
``ADC_ATTEN_DB_6`` {IDF_TARGET_ADC_V_MIN_ATTEN2} mV ~ {IDF_TARGET_ADC_V_MAX_ATTEN2} mV ``ADC_ATTEN_DB_6`` {IDF_TARGET_ADC_V_MIN_ATTEN2} mV ~ {IDF_TARGET_ADC_V_MAX_ATTEN2} mV
``ADC_ATTEN_DB_11`` {IDF_TARGET_ADC_V_MIN_ATTEN3} mV ~ {IDF_TARGET_ADC_V_MAX_ATTEN3} mV ``ADC_ATTEN_DB_12`` {IDF_TARGET_ADC_V_MIN_ATTEN3} mV ~ {IDF_TARGET_ADC_V_MAX_ATTEN3} mV
===================== ========================================================================================================= ===================== =========================================================================================================

View File

@ -33,7 +33,7 @@ static const char *TAG_CH[2][10] = {{"ADC1_CH2"}, {"ADC2_CH0"}};
#endif #endif
//ADC Attenuation //ADC Attenuation
#define ADC_EXAMPLE_ATTEN ADC_ATTEN_DB_11 #define ADC_EXAMPLE_ATTEN ADC_ATTEN_DB_12
//ADC Calibration //ADC Calibration
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32

View File

@ -274,7 +274,7 @@ void adc_read_task(void* arg)
adc1_config_width(ADC_WIDTH_12Bit); adc1_config_width(ADC_WIDTH_12Bit);
adc1_config_channel_atten(ADC1_TEST_CHANNEL, ADC_ATTEN_11db); adc1_config_channel_atten(ADC1_TEST_CHANNEL, ADC_ATTEN_11db);
esp_adc_cal_characteristics_t characteristics; esp_adc_cal_characteristics_t characteristics;
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, V_REF, &characteristics); esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_12, ADC_WIDTH_BIT_12, V_REF, &characteristics);
while(1) { while(1) {
uint32_t voltage; uint32_t voltage;
esp_adc_cal_get_voltage(ADC1_TEST_CHANNEL, &characteristics, &voltage); esp_adc_cal_get_voltage(ADC1_TEST_CHANNEL, &characteristics, &voltage);

View File

@ -96,7 +96,7 @@ void app_main(void)
#elif CONFIG_IDF_TARGET_ESP32S2 #elif CONFIG_IDF_TARGET_ESP32S2
adc1_config_width(ADC_WIDTH_BIT_13); adc1_config_width(ADC_WIDTH_BIT_13);
#endif #endif
adc1_config_channel_atten(ADC1_TEST_CHANNEL, ADC_ATTEN_DB_11); adc1_config_channel_atten(ADC1_TEST_CHANNEL, ADC_ATTEN_DB_12);
ESP_LOGI(TAG, "Enabling CW generator on DAC channel 1 / GPIO%d.", DAC_CHANNEL_1_GPIO_NUM); ESP_LOGI(TAG, "Enabling CW generator on DAC channel 1 / GPIO%d.", DAC_CHANNEL_1_GPIO_NUM);
enable_cosine_generator(); enable_cosine_generator();

View File

@ -63,7 +63,7 @@ static void init_ulp_program(void)
/* Configure ADC channel */ /* Configure ADC channel */
/* Note: when changing channel here, also change 'adc_channel' constant /* Note: when changing channel here, also change 'adc_channel' constant
in adc.S */ in adc.S */
adc1_config_channel_atten(ADC1_CHANNEL_6, ADC_ATTEN_DB_11); adc1_config_channel_atten(ADC1_CHANNEL_6, ADC_ATTEN_DB_12);
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
adc1_config_width(ADC_WIDTH_BIT_12); adc1_config_width(ADC_WIDTH_BIT_12);
#elif CONFIG_IDF_TARGET_ESP32S2 #elif CONFIG_IDF_TARGET_ESP32S2

View File

@ -8,7 +8,7 @@
#include "hal/adc_types.h" #include "hal/adc_types.h"
#define EXAMPLE_ADC_CHANNEL ADC_CHANNEL_0 #define EXAMPLE_ADC_CHANNEL ADC_CHANNEL_0
#define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_11 #define EXAMPLE_ADC_ATTEN ADC_ATTEN_DB_12
#define EXAMPLE_ADC_WIDTH ADC_WIDTH_BIT_12 #define EXAMPLE_ADC_WIDTH ADC_WIDTH_BIT_12
/* Set high threshold, approx. 1.75V*/ /* Set high threshold, approx. 1.75V*/